已在视图中找到组件ID.重复ui:执行ajax功能后重复元素



我使用的是JSF Mojarra 2.2和Primefaces 4.0。

在我的页面上,我使用<ui:repeat>来呈现一些数据表。通过单击单行元素的name列,该行的附加信息将通过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>

似乎是错误地将具有相同id的<ui:repeat>多次插入到文档树中。

该问题仅在与ajax功能结合使用时才会出现。如果我在<p:commandLink>中设置ajax="false",我不会得到任何错误。

请帮助我理解为什么会发生这种情况以及如何避免!

正如BalusC在评论中所说,我使用<p:dataList type="none">来替换<ui:repeat>,这解决了错误。

相关内容

  • 没有找到相关文章

最新更新