Note that there are some explanatory texts on larger screens.

plurals
  1. POh:dataTable binding => duplicate ID
    text
    copied!<p>I have a problem using HtmlDataTable for viewing data from database.</p> <p>When I create component, the table has sometimes (not always) <strong>twice number of columns</strong>.</p> <p>It is shown correctly and after several refreshes (without move in dtb or something) there is for example 6 columns instead of 3 and application (sometimes) become unstable. Since this time I can't work with table because it reports "duplicate Id for a component"..</p> <p>Simple example (source: <a href="http://balusc.blogspot.com/2006/06/using-datatables.html" rel="nofollow">http://balusc.blogspot.com/2006/06/using-datatables.html</a>): </p> <pre><code>&lt;h:form id="bde"&gt; &lt;h:dataTable id="tbl" binding="#{myBDE.dataTable}" value="#{myBDE.dataList}" var="bdeItem"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="S" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{bdeItem.s}" rendered="#{!myBDE.editModeRow}"/&gt; &lt;h:inputText value="#{bdeItem.s}" rendered="#{myBDE.editModeRow}" required="true" size="3"/&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="ID" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{bdeItem.id}"/&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;/h:form&gt; </code></pre> <p>And java.class </p> <pre><code>protected HtmlDataTable dataTable; public void setDataTable(HtmlDataTable dataTable) { this.dataTable = dataTable; } public HtmlDataTable getDataTable() { if (dataTable == null) { dataTable = new HtmlDataTable(); dataTable.setRows(DEFAULT_TABLE_ROWS); } return dataTable; } </code></pre> <p>And the Error message: </p> <pre><code>javax.servlet.ServletException: Component ID j_idt92:bde:tbl:j_idt129 has already been found in the view. javax.faces.webapp.FacesServlet.service(FacesServlet.java:422) root cause java.lang.IllegalStateException: Component ID j_idt92:bde2:tbl:j_idt129 has already been found in the view. com.sun.faces.util.Util.checkIdUniqueness(Util.java:821) com.sun.faces.util.Util.checkIdUniqueness(Util.java:805) com.sun.faces.util.Util.checkIdUniqueness(Util.java:805) com.sun.faces.util.Util.checkIdUniqueness(Util.java:805) com.sun.faces.util.Util.checkIdUniqueness(Util.java:805) com.sun.faces.util.Util.checkIdUniqueness(Util.java:805) com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:144) com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:133) com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225) com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:418) com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) javax.faces.webapp.FacesServlet.service(FacesServlet.java:410) </code></pre> <p>Followed by tree of components. I thing there's nothing duplicated in code, but dataTable create a new columns and after that it's really duplicated</p> <p>I have two working similar modules, and the third doesn´t work.</p> <p>Have you ever met this kind of problem?</p> <p>Thanks for advice</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload