Идентификатор компонента уже найден в представлении. Дублировать элемент ui:repeat после выполнения функций ajax

Я использую JSF Mojarra 2.2 и Primefaces 4.0.

На моей странице я использую <ui:repeat> для отображения некоторых таблиц данных. При нажатии на столбец имени одного элемента строки дополнительная информация для этой строки загружается через ajax и отображается под таблицами в отдельной панели. Страница отображается нормально и ведет себя так, как ожидалось в начале. После нескольких кликов и загрузки дополнительной информации через ajax я получаю:

java.lang.IllegalStateException: Component ID has already been found in the view. 

Подробное сообщение об ошибке

+id: dcvForm
 type: javax.faces.component.html.HtmlForm@19aa202
  +id: j_idt34
   type: org.primefaces.component.scrollpanel.ScrollPanel@1025e3c
    +id: j_idt35
     type: org.primefaces.component.outputpanel.OutputPanel@78eb00
      +id: j_idt40  <===============
       type: com.sun.faces.facelets.component.UIRepeat@194a115
        +id: j_idt41
         type: org.primefaces.component.datatable.DataTable@db8d63
          +id: j_idt42
           type: javax.faces.component.html.HtmlOutputText@1f6f6f
          +id: j_idt43
           type: org.primefaces.component.column.Column@1ccf811
            +id: j_idt44
             type: javax.faces.component.html.HtmlOutputText@1b22d38
            +id: j_idt45
             type: javax.faces.component.html.HtmlOutputText@b6cbe4
          +id: j_idt46
           type: org.primefaces.component.column.Column@103f78a
            +id: j_idt47
             type: javax.faces.component.html.HtmlOutputText@1708cb9
            +id: j_idt48
             type: javax.faces.component.html.HtmlOutputText@26ed67
          +id: j_idt49
           type: org.primefaces.component.column.Column@1ac1194
            +id: j_idt50
             type: javax.faces.component.html.HtmlOutputText@1b61dd7
            +id: j_idt51
             type: javax.faces.component.html.HtmlOutputText@1614aa1
          +id: j_idt52
           type: org.primefaces.component.column.Column@6a93d0
            +id: j_idt53
             type: javax.faces.component.html.HtmlOutputText@10e3ef3
            +id: j_idt54
             type: javax.faces.component.html.HtmlOutputText@46fd81
          +id: j_idt55
           type: org.primefaces.component.column.Column@ad5082
            +id: j_idt56
             type: javax.faces.component.html.HtmlOutputText@808a3a
            +id: j_idt57
             type: javax.faces.component.html.HtmlOutputText@f31547
      +id: j_idt40  <===============
       type: com.sun.faces.facelets.component.UIRepeat@fa2760
        +id: j_idt41
         type: org.primefaces.component.datatable.DataTable@12f4785
          +id: j_idt42
           type: javax.faces.component.html.HtmlOutputText@1007ab4
          +id: j_idt43
           type: org.primefaces.component.column.Column@77deb5
            +id: j_idt44
             type: javax.faces.component.html.HtmlOutputText@1be73ae
            +id: j_idt45
             type: javax.faces.component.html.HtmlOutputText@9cd7aa
          +id: j_idt46
           type: org.primefaces.component.column.Column@113119b
            +id: j_idt47
             type: javax.faces.component.html.HtmlOutputText@e8ee3b
            +id: j_idt48
             type: javax.faces.component.html.HtmlOutputText@7083c1
          +id: j_idt49
           type: org.primefaces.component.column.Column@da0bb8
            +id: j_idt50
             type: javax.faces.component.html.HtmlOutputText@1378ca7
            +id: j_idt51
             type: javax.faces.component.html.HtmlOutputText@1f360fc
          +id: j_idt52
           type: org.primefaces.component.column.Column@16454e1
            +id: j_idt53
             type: javax.faces.component.html.HtmlOutputText@aea7
            +id: j_idt54
             type: javax.faces.component.html.HtmlOutputText@ca6240
          +id: j_idt55
           type: org.primefaces.component.column.Column@f8833d
            +id: j_idt56
             type: javax.faces.component.html.HtmlOutputText@17033ef
            +id: j_idt57
             type: javax.faces.component.html.HtmlOutputText@161bdc8
      +id: j_idt36
       type: org.primefaces.component.datatable.DataTable@8c5a93
        +id: j_idt37
         type: javax.faces.component.html.HtmlOutputText@8ea6b9
        +id: j_idt38
         type: org.primefaces.component.column.Column@163dfdf
          +id: j_idt39
           type: javax.faces.component.html.HtmlOutputText@1fec9fc
          +id: ElementName
           type: org.primefaces.component.commandlink.CommandLink@7edb15
          +id: ceIndex
           type: javax.faces.component.html.HtmlInputHidden@617652
      +id: j_idt40
       type: com.sun.faces.facelets.component.UIRepeat@9f1948
        +id: j_idt41
         type: org.primefaces.component.datatable.DataTable@134c649
          +id: j_idt42
           type: javax.faces.component.html.HtmlOutputText@1c60a38
          +id: j_idt43
           type: org.primefaces.component.column.Column@c9054a
            +id: j_idt44
             type: javax.faces.component.html.HtmlOutputText@17a7e4d
            +id: j_idt45
             type: javax.faces.component.html.HtmlOutputText@fa11ca
          +id: j_idt46
           type: org.primefaces.component.column.Column@1a5e64c
            +id: j_idt47
             type: javax.faces.component.html.HtmlOutputText@b2c0d7
            +id: j_idt48
             type: javax.faces.component.html.HtmlOutputText@1929f1c
          +id: j_idt49
           type: org.primefaces.component.column.Column@10be919
            +id: j_idt50
             type: javax.faces.component.html.HtmlOutputText@f47006
            +id: j_idt51
             type: javax.faces.component.html.HtmlOutputText@1e6c683
          +id: j_idt52
           type: org.primefaces.component.column.Column@1f2e85c
            +id: j_idt53
             type: javax.faces.component.html.HtmlOutputText@7517ff
            +id: j_idt54
             type: javax.faces.component.html.HtmlOutputText@17a69a8
          +id: j_idt55
           type: org.primefaces.component.column.Column@1aececc
            +id: j_idt56
             type: javax.faces.component.html.HtmlOutputText@18ac146
            +id: j_idt57
             type: javax.faces.component.html.HtmlOutputText@9714e6
  +id: j_idt58
   type: 
        <p/>

  +id: filterInfoPanel
   type: org.primefaces.component.outputpanel.OutputPanel@dd2f52
    +id: j_idt59
     type: com.sun.faces.facelets.component.UIRepeat@14ddafe
      +id: j_idt60
       type: org.primefaces.component.outputpanel.OutputPanel@64760f
        +id: j_idt61
         type: javax.faces.component.html.HtmlOutputLabel@183001f
        +id: j_idt62
         type: 
                    <p/>

        +id: j_idt63
         type: javax.faces.component.html.HtmlOutputLabel@17d098a
    +id: ajaxStatusPanel
     type: org.primefaces.component.ajaxstatus.AjaxStatus@1fd5640
      +id: j_idt64
       type: javax.faces.component.html.HtmlGraphicImage@1299e6a
      +id: j_idt65
       type: javax.faces.component.html.HtmlGraphicImage@15f6084
+id: j_idt66
 type:          
    </div>

Моя страница xhtml

<ui:define name="content">
                    <h:form id="dcvForm">
                        <p:scrollPanel mode="native">
                            <p:outputPanel style="white-space: nowrap;">
                                <p:dataTable var="rowElement" binding="#{nameTable}"
                                    value="#{domainComparisonBean.firstDomainElements}"
                                    style="display:inline-block;">
                            [...]   
                                        <p:commandLink id="ElementName" value="#{rowElement.name}"
                                            actionListener="#{domainComparisonBean.mouseOver}"
                                            update=":dcvForm:filterInfoPanel" ajax="true" >
                                        </p:commandLink>
                            [...]
                                </p:dataTable>

                                <ui:repeat var="domain" value="#{domainComparisonBean.domainData}"
                                    varStatus="status">
                                    <p:dataTable var="rowElement" value="#{domain.rowData}"
                                        style="display:inline-block;" selectionMode="single"
                                        selection="#{domainComparisonBean.selectedRow}">

                            [...]

                                    </p:dataTable>
                                </ui:repeat>
                            </p:outputPanel>
                        </p:scrollPanel>
                        <p />
                        <p:outputPanel id="filterInfoPanel"
                            style="border:none; margin-left:10px;">
                            <ui:repeat var="filter"
                                value="#{domainComparisonBean.currentFilters}" varStatus="status">
                            [...]               
                            </ui:repeat>
                        </p:outputPanel>
                    </h:form>
                </ui:define>

Кажется, что по ошибке <ui:repeat> вставляется несколько раз с одним и тем же идентификатором в дерево документов.

Проблема возникает только в сочетании с функциональностью ajax. Если я установлю ajax="false" в своем <p:commandLink>, я не получу никаких ошибок.

Пожалуйста, помогите мне понять, почему это происходит и как этого избежать!


person nilsfried    schedule 20.02.2014    source источник
comment
Какая именно версия Мохарры? 2.2.0? Пробовали последнюю? В любом случае попробуйте присвоить затронутому компоненту фиксированный идентификатор. Чаще всего это устраняет подобную сложную проблему с сохранением состояния. Или замените <ui:repeat> на <p:dataList type="none">. В отличие от Mojarra UIRepeat, компоненты на основе UIData имеют гораздо более надежную реализацию сохранения состояния.   -  person BalusC    schedule 21.02.2014
comment
Я обновился до Mojarra 2.2.5, но ошибка осталась. Предоставление затронутому <ui:repeat id="tableRepeat"> просто приводит к +id: tableRepeat <=============== type: com.sun.faces.facelets.component.UIRepeat@148bce2 в сообщении об ошибке   -  person nilsfried    schedule 21.02.2014
comment
Ладно, попробуй другой компонент повторителя. UIRepeat от Mojarra ранее было очень много ошибок сохранения состояния. Многое исправлено, но это видимо очередной недосмотр.   -  person BalusC    schedule 21.02.2014
comment
Я попробовал <p:dataList> и больше не получаю ошибку. Благодарю вас! Однако мой контент раньше отображался рядом (по вертикали), а теперь отображается друг под другом (по горизонтали). У вас есть совет, как я могу добиться вертикального позиционирования с помощью <p:dataList>?   -  person nilsfried    schedule 21.02.2014
comment
Возможно, вы забыли type="none"?   -  person BalusC    schedule 21.02.2014
comment
Нет, проблема не в <p:dataList>, а в самом элементе. Я пытаюсь сделать его плавающим, установив style="display:inline-block;", но он все равно ломается.   -  person nilsfried    schedule 21.02.2014
comment
Что ж, нажмите кнопку «Задать вопрос» в правом верхнем углу и опубликуйте SSCCE. На текущий вопрос технически уже дан ответ :)   -  person BalusC    schedule 21.02.2014


Ответы (1)


Как заявил BalusC в комментариях, я использовал <p:dataList type="none"> для замены <ui:repeat>, что устраняет ошибку.

person nilsfried    schedule 20.02.2014