title: binding on p:dataTable which is included multiple times causes ID unqiueness exceptions
body: <p>I'm attempting to use a special PrimeFaces data exporter implementation as being used in this answer:</p>
  
  <p><a href="https://stackoverflow.com/a/14413932/396732">https://stackoverflow.com/a/14413932/396732</a></p>
  
  <p>Our use case however is a little more complex, e.g. using Facelets to show the respective datatable for export, which has row expansions with sub tables in them.</p>
  
  <p><strong>insiderListManagerDialogs.xhtml:</strong></p>
  
  <pre><code>&lt;ui:include src="insiderListManagerListDialog.xhtml"&gt;
      &lt;ui:param name="idPrefix" value="il-emp" /&gt;
      &lt;ui:param name="widgetVarPrefix" value="ilEmp" /&gt;
      &lt;ui:param name="dialogTitle" value="#{msg['entity.employee.internal.plural.label']}" /&gt;
      &lt;ui:param name="mapPropertyName" value="insiderListEmployeesMap" /&gt;
      &lt;ui:param name="sortColumn" value="#{ent.lastTime}" /&gt;
      &lt;ui:param name="keyColumnsXhtml" value="listDialogInsiderListKeyColumns.xhtml" /&gt;
      &lt;ui:param name="valueColumnsXhtml" value="listDialogEmployeeValueColumns.xhtml" /&gt;
  &lt;/ui:include&gt;
  </code></pre>
  
  <p><strong>insiderListManagerListDialog.xhtml:</strong></p>
  
  <pre><code>&lt;p:dialog id="#{idPrefix}-il-view-dialog"
            widgetVar="#{widgetVarPrefix}Dialog"
            header="#{dialogTitle}"
            modal="true"
            resizable="false"
            appendToBody="true" 
            onShow="resetFilterInput( '#{idPrefix}' );"
            width="1000"
            height="750"&gt;
  
      &lt;h:form id="#{idPrefix}-il-view-form"&gt;
          &lt;p:dataTable id="list-entities"
                       widgetVar="listEntitiesTable"
                       binding="#{table}"
                       value="#{insiderListManager.listInstances}"
                       var="key"
                       scrollable="true"
                       scrollHeight="625"
                       scrollWidth="985"
                       resizableColumns="true"
                       expandedRow="#{insiderListManager.listEntitiesRowTogglerOpen}"
                       filteredValue="#{insiderListManager.filteredEntities}"
                       sortBy="#{sortColumn}"
                       styleClass="bx-datatable-header-hidden-m"
                   tyle="width: 970px;"&gt;
  
              &lt;f:facet name="header"&gt;
                  &lt;p:inputText id="globalFilter"
                               onkeypress="if (event.keyCode == 13) { listEntitiesTable.filter(); return false;}"
                               size="70"
                               styleClass="bx-dt-header-element" /&gt;
                  &lt;p:commandButton id="search-btn"
                                   icon="ui-icon bx-icon-search"
                                   value="#{msg['common.action.search.label']}"
                                   process="@this"
                                   onclick="listEntitiesTable.filter(); return false;"
                                   styleClass="bx-dt-header-element" /&gt;            
                  &lt;p:commandButton title="#{msg['common.action.excelExport.all.hint']}"
                                   icon="ui-icon bx-icon-excel"
                                   action="#{insiderListManager.exportXls( table )}"
                                   ajax="false"
                                   styleClass="bx-button-border bx-dt-header-element" /&gt;
                   &lt;div class="bx-clear-float" /&gt;
              &lt;/f:facet&gt;
  
              &lt;p:column width="15"
                        resizable="false"&gt;
  
              ...
  
              &lt;p:rowExpansion&gt; 
                  &lt;p:dataTable value="#{insiderListManager[mapPropertyName].get(key)}"
                               var="value"&gt;
  
                      &lt;ui:include src="#{valueColumnsXhtml}" /&gt;
  
                  &lt;/p:dataTable&gt;
              &lt;/p:rowExpansion&gt; 
          &lt;/p:dataTable&gt;
  
          &lt;h:panelGroup id="button-panel" layout="block" styleClass="left-button-panel mt-5px"&gt;
              &lt;p:commandButton id="toggle-button"
                               icon="#{insiderListManager.listEntitiesRowTogglerOpen ? 'ui-icon ui-icon-circle-triangle-e' : 'ui-icon ui-icon-circle-triangle-s'}"
                               value="#{insiderListManager.listEntitiesRowTogglerOpen ? msg['common.action.collapseAll.label'] : msg['common.action.expandAll.label']}"
                               process="@this"
                               update="@form"&gt;
                  &lt;f:setPropertyActionListener target="#{insiderListManager.listEntitiesRowTogglerOpen}"
                                               value="#{not insiderListManager.listEntitiesRowTogglerOpen}" /&gt;
              &lt;/p:commandButton&gt;
          &lt;/h:panelGroup&gt;
  
      &lt;/h:form&gt;
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>Note the </p>
  
  <pre><code>&lt;p:commandButton title="..."
                   icon="ui-icon bx-icon-excel"
                   action="#{insiderListManager.exportXls( table )}"
                   ... /&gt;
  </code></pre>
  
  <p>which is using the bound data table as described in the link posted at the top.</p>
  
  <p>We are using <strong>JSF 2.1</strong> (Mojarra 2.1.22 - and we cannot switch to MyFaces) which allows expressions to construct IDs like <code>#{idPrefix}-il-view-dialog</code> from a <code>&lt;ui:param name="idPrefix" value="il-emp" /&gt;</code>.</p>
  
  <p>However, we are getting ID uniqueness exception:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Component ID il-emp-il-view-form:list-entities:globalFilter has already been found in the view.  
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:846)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.util.Util.checkIdUniqueness(Util.java:830)
      at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:144)
      at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:133)
      at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:419)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
      at com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163)
      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
      ... 49 more
  </code></pre>
  
  <p>Same happens to other buttons with explicit IDs if omitted, e.g. the search button (<code>&lt;p:commandButton id="search-btn" ...</code>).</p>
  
  <p><strong>QUESTION</strong>:</p>
  
  <p>Why is this happening and how can we avoid this problem when we are bound to using PrimeFaces dialogs for each use case displayed? (we have more than one dialog)</p>
  
  <p>Note that when removing the <code>&lt;p:dataTable ... binding="..."</code> the page works correctly.</p>