11 Replies Latest reply: Jul 7, 2008 6:56 AM by Luca Borzani RSS

duplicate Id for a component

Juan Ignacio Sánchez Lara Apprentice

I was using MyFaces and I wanted to switch to JSF RI (I'd better say I've been told to). Since I've switched I get "duplicate Id for a component" errors really often, specially at rich:tabPanel-ed pages.

Has anybody had this problem before?

  • 1. Re: duplicate Id for a component
    Abdulla Abdurakhmanov Newbie

    Yes!
    I had some problem for tabbed pages. But I can't to reproduce and localize this for a small example.

  • 2. Re: duplicate Id for a component
    Juan Ignacio Sánchez Lara Apprentice

    Using Sun RI? Did you solve it?

  • 3. Re: duplicate Id for a component
    Abdulla Abdurakhmanov Newbie

    Yes, I'm using Sun RI in GlassFish v2.
    But I can't solve this for now.

  • 4. Re: duplicate Id for a component
    Juan Ignacio Sánchez Lara Apprentice

    Mmm... Glasfish v2, so you'll probably be using JSF 1.2, that's supposed to be a much better implementation. People who are stuck at 1.1 are f****d up :-\

  • 5. Re: duplicate Id for a component
    Sergey Smirnov Master

    duplicateId is not only the problem of JSF 1.1. If you look at the lists of fixed bug for JSF 1.2 and facelets, you can find a lot of entries about fixing.

  • 6. Re: duplicate Id for a component
    Juan Ignacio Sánchez Lara Apprentice

    I'll stay with MyFaces then, it gives me no duplicatedId problem at all.

    Thanks!

  • 7. Re: duplicate Id for a component
    Yurii Kartsev Apprentice

    Good afternoon.

    I've faced the same problem right now. Can't find a solution. I have a scrollable dataTable on my page and while it's displaying, facelets give me this error: "duplicate Id for a component staffDataTable_Form:staffDataTable:j_id33".

    The strange thing is that I have two pages with such table with the same information in it. But only one gives me this error.

    Here is my staff.xml (which gives the error):

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns:f="http://java.sun.com/jsf/core"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     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">
    
    <!--<a4j:commandButton action="#{amBean.action4EmployeeAddNewAnketa}" value="Add" focus="employeeTab" reRender=":employeesDataTable_form:employeesDataTable,:anketaTabPanel"></a4j:commandButton>-->
    
    
    <ui:composition template="/hr_template.xhtml">
    
     <ui:define name="toolbar">
     <ui:include src="hr_toolbar.xhtml"/>
     </ui:define>
    
    
     <ui:define name="tree">
    
     <rich:separator height="1" style="padding:10px" />
     <h:form id="structureTree_form">
    
     <rich:tree style="width:250px" id="structureTree" styleClass="tree" switchType="ajax"
     ajaxSubmitSelection="true" showConnectingLines="true"
     changeExpandListener="#{treeMan.onDepartmentTreeExpand}"
     nodeSelectListener="#{treeMan.onDepartmentTreeSelect}"
     stateAdvisor="#{departmentTreeStateAdvisor}">
     <rich:recursiveTreeNodesAdaptor roots="#{treeMan.departmentsTreeRoots}" var="item" nodes="#{item.nodes}" />
     </rich:tree>
    
     </h:form>
     <rich:separator height="1" style="padding:10px;" />
    
    
     </ui:define>
    
    
    
    <c:if test="#{amBean.isError}">
     <ui:define name="result">
     Changed Result
     </ui:define>
    </c:if>
    
     <ui:define name="data">
    
     <h:form id="staffDataTable_Form">
     <rich:scrollableDataTable height="200px" rowKeyVar="rkv" frozenColCount="1"
     binding="#{staffSDTableMan.sdTable}" selection="#{staffSDTableMan.scrollableDataTableSelection}"
     rowClasses="sdt_row1,sdt_row2" selectedClass="sdt_row_selected" activeClass="sdt_row_active"
     width="470px" id="staffDataTable" rows="#{amBean.employeeListMan.listSize}" columnClasses="sdt_col"
     value="#{amBean.employeeListMan.employees}" var="employee" sortMode="single">
    
     <rich:column id="firstName">
     <f:facet name="header"><h:outputText styleClass="sdt_head" value="First Name" /></f:facet>
     <h:outputText value="#{employee.firstName}" />
     </rich:column>
    
     <rich:column id="lastName">
     <f:facet name="header"><h:outputText styleClass="sdt_head" value="Last Name" /></f:facet>
     <h:outputText value="#{employee.lastName}" />
     </rich:column>
    
     <rich:column id="sex">
     <f:facet name="header"><h:outputText styleClass="sdt_head" value="Sex" /></f:facet>
     <h:outputText value="#{employee.sex}" />
     </rich:column>
    
     <rich:column id="birthDate">
     <f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Date" /></f:facet>
     <h:outputText value="#{employee.birthDate}" />
     </rich:column>
    
     <rich:column id="birthPlace">
     <f:facet name="header"><h:outputText styleClass="sdt_head" value="Birth Place" /></f:facet>
     <h:outputText value="#{employee.birthPlace}" />
     </rich:column>
    
     </rich:scrollableDataTable>
    
     <BR style="text-size:3px;"/>
    
     <a4j:commandButton action="#{staffSDTableMan.prepareNewWorker}" value="Make prikaz"></a4j:commandButton>
    
     </h:form>
    
    
     <c:if test="#{staffSDTableMan.isNewWorker}">
     New Worker added!
     </c:if>
     <c:if test="#{!staffSDTableMan.isNewWorker}">
     New Worker was not added!
     </c:if>
     </ui:define>
    
    </ui:composition>
    </html>



    I use JSF 1.2, Facelets, RichFaces 3.1.0.


    Thanks in advance. Any advice would be appreciated.

  • 8. Re: duplicate Id for a component
    Yurii Kartsev Apprentice

    staff.xml = staff.xhtml (sorry for that)

    P.S.: This page opens from the page where the same scrollableDataTable is. So user goes there, selects a row, presses a commandButton and is redirected to staff.xhtml(where the error appears).

  • 9. Re: duplicate Id for a component
    Luca Borzani Newbie

    solutions? i'm continously afflicted by this obscure problem...thinking about changing framework...

  • 10. Re: duplicate Id for a component
    Ilya Shaikovsky Master

    This could be caused by session scoped beans which holds components bindings.

  • 11. Re: duplicate Id for a component
    Luca Borzani Newbie

    i have no beans in session scope :(