11 Replies Latest reply on Mar 18, 2009 8:44 AM by Mahesh Thirunavukkarasu

    How to avoid duplicate id in component

    Mahesh Thirunavukkarasu Newbie

      Hi
      I need to design datatable with dynamic number of columns, so i was try to design <rich:datatable> with <rich:columns> tag, that produces
      javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component id

      I was come across multiple posts they suggest to avoid duplicate id exception assign id for every component. I have tried like that even problem comes. I have enclosed page code and stack trace with this post.

      <rich:dataTable id="sampleDataTable" value="#{Sample.dataList}" var="record">
      <f:facet name="header">
      <rich:columnGroup id="headerColumnGroup">
      <rich:column id="nameColumnHeader" rowspan="2">
      <h:outputText value="Name"/>
      </rich:column>
      <rich:column id="itemsColumnHeader" colspan="3">
      <h:outputText value="Items" />
      </rich:column>
      <rich:column id="firstItemHeader" breakBefore="true">
      <h:outputText value="Item-1" />
      </rich:column>
      <rich:columns id="itemColumns" columns="2">
      <h:outputText value="Item"/>
      </rich:columns>
      </rich:columnGroup>
      </f:facet>
      <rich:column id="nameColumn">
      <h:outputText value="#{record.name}"/>
      </rich:column>
      <rich:columns id="selectItem" columns="3">
      <h:selectBooleanCheckbox id="categoryCheckBox"/>
      </rich:columns>
      </rich:dataTable>

      Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
      com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:473)
      com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:141)
      org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

      javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component id: 'sampleForm:sampleDataTable:rf0', first used in tag: 'org.richfaces.taglib.ColumnsTag'
      +id: j_id_jsp_935888301_0