2 Replies Latest reply on Oct 22, 2010 5:48 AM by Ilya Shaikovsky

    Cant get rid of "duplicate Id for a component "

    Satya K Newbie

      Hi All,

       

      I am not sure how and where the IDs of components are duplicated. But I do set the IDs manually and eventhen I get this exception.

       

      Below is the code of my xhtml which uses a Extended DataTable.

       

      Can you let me know if I am doing something wrong in the code?

       

      <code>

      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:c="http://java.sun.com/jstl/core"
           xmlns:rich="http://richfaces.org/rich" >

       

          <ui:composition>
              <a4j:loadStyle src="#{navMsgs.UtilityApplication}/theme/applicationStyle.css" />
              <h:form id="extTblForm">
                  <rich:comboBox id="idSubMatrixListTemp" value="#{channelsBean.selectedSubMatrix}"
                      suggestionValues="#{channelsBean.subMatrixList}"
                      directInputSuggestions="true" selectFirstOnUpdate="false" enableManualInput="false"
                      defaultLabel="#{channelMessages.selectSubMatrix}" immediate="true" width="200"
                      valueChangeListener="#{channelsBean.updateSelectedSubMatrix}">
                      <a4j:support event="onselect" reRender="idChannelsTable,channelsBreadcrumb" ajaxSingle="true" requestDelay="50"
                      onsubmit="#{rich:component('panel')}.show()" oncomplete="#{rich:component('panel')}.hide()" />
                      <f:converter converterId="ComboConverter"/>
                  </rich:comboBox>
                  <rich:spacer height="15" width="1" id="extSpacer"  />

       

                  <rich:extendedDataTable id="idChannelsTable"
                      width="1000px" height="600px" style="border: 1px 0px 1px 0px;"
                      value="#{channelsBean.channelsList}"
                      selection="#{channelsBean.selection}"
                      var="channelAttr" sortMode="single"
                      binding="#{channelsBean.idChannelsExtTable}"
                      selectionMode="single">

       

                      <rich:column sortable="false" label="Name" width="250px" filterBy="#{channelAttr.name}" filterEvent="onchange">
                          <f:facet name="header">
                              <h:outputText value="Name" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.name}" />
                      </rich:column>
                      <rich:column sortable="false" label="Minimum" width="150px">
                          <f:facet name="header">
                              <h:outputText value="Minimum" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.minimum}" />
                      </rich:column>
                      <rich:column sortable="false" label="Maximum" width="150px">
                          <f:facet name="header">
                              <h:outputText value="Maximum" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.maximum}" />
                      </rich:column>
                      <rich:column sortable="false" label="Independent Flag" width="150px">
                          <f:facet name="header">
                              <h:outputText value="Independent Flag" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.independentFlag}" />
                      </rich:column>
                      <rich:column sortable="false" label="Global Flag" width="150px">
                          <f:facet name="header">
                              <h:outputText value="Global Flag" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.globalFlag}" />
                      </rich:column>
                      <rich:column sortable="false" label="Generation Parameters" width="150px">
                          <f:facet name="header">
                              <h:outputText value="Generation Parameters" />
                          </f:facet>
                          <h:outputText value="#{channelAttr.generationParameters}" />
                      </rich:column>
                     
                      <a4j:support event="ondblclick"
                          onsubmit="#{rich:component('panel')}.show()" oncomplete="#{rich:component('panel')}.hide()"
                          requestDelay="500" action="#{channelsBean.addChannelsToCart}" ajaxSingle="true"
                          reRender="idChannelsTable, idShopingCartPanel" />
                     
                  </rich:extendedDataTable>
              </h:form>
          </ui:composition>
      </html>

      </code>

       

      Below is the extract of the exception

       

      14:02:58,607 INFO  [STDOUT] 14:02:58,607 ERROR [BaseXMLFilter] Exception in the filter chain
      javax.servlet.ServletException: duplicate Id for a component extTblForm:idChannelsTable:j_id181
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:532)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
          at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:402)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalStateException: duplicate Id for a component extTblForm:idChannelsTable:j_id181
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:68)
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
          at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)
          at org.ajax4jsf.application.AjaxStateManager.getTreeStructureToSave(AjaxStateManager.java:187)
          at org.ajax4jsf.application.AjaxStateManager.buildViewState(AjaxStateManager.java:473)
          at org.ajax4jsf.application.AjaxStateManager.saveSerializedView(AjaxStateManager.java:426)
          at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:615)
          at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
          at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
          at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
          at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)

       

      Regards,

      Satya

        • 1. Re: Cant get rid of "duplicate Id for a component "
          Satya K Newbie

          I was able to solve the Duplicate ID problem by removing the binding property and implement the row selection by below code:

           

          Iterator<Object> iterator = getSelection().getKeys();

                  ChannelAttributes ch = null;

                   while (iterator.hasNext()) {

                      Object selectedRowNum = iterator.next();

                      ch = channelsList.get((Integer)selectedRowNum);

                  }

           

          But with this I face another new problem i.e selection of table row is wrong when data is filtered.

           

          I mean, if user filters the table data based on a column and selects a row (based on the filter result), correct row is not selected.

          Ex: If I select 1st row after filter, the selected row will be 1st row which was before filter.

           

          Is it possible to get correct row from the filtered result without using binding property of the ExtendedDataTable?

           

          Regards,

          Satya

          • 2. Re: Cant get rid of "duplicate Id for a component "
            Ilya Shaikovsky Master

            original problem caused by binding. it was session scoped I guess. It's one of the most known problems in JSF (in our FAQ also)

             

            And the last problem also really easy to solve. You using selection by just index - so it works as it should, but you need to use rowKeys. download richfaces demo - extendedDataTable sample has it implemented using simple with  realy simple dataProvider.