2 Replies Latest reply: Feb 23, 2012 4:19 AM by Björn Meyer RSS

Duplicate Id error when using binding on rich:tree

Björn Meyer Newbie

I'm experiencing a strange problem with my rich:tree using Richfaces 3.3.3.

 

I want to have the UITree in my backing bean, so I can do node expanding / collapsing etc. in my code. But when I add a binding to the rich:tree I get duplicate Id errors during rendering. (com.sun.facelets.FaceletViewHandler handleRenderException FATAL: Error Rendering View[...] java.lang.IllegalStateException: duplicate Id for a component ...)

 

On a different rich:tree (in the same application) with a very similar structure this works without any problems.

 

When I searched the forum for this I found posts saying that the binding should not be put in a session bean. (My bean here is a session bean.) But how come this works fine for one tree but not for the other?

  • 1. Re: Duplicate Id error when using binding on rich:tree
    Mark Paluch Master

    can you post some code?

  • 2. Re: Duplicate Id error when using binding on rich:tree
    Björn Meyer Newbie

    Sure!

     

    This is basically a tree with different types of nodes:

     

    <rich:tree ajaxSubmitSelection="true" id="userTree" switchType="ajax" reRender="userAdminDetails" toggleOnClick="false"
                value="#{userBean.richtreeData}" binding="#{userBean.richtreeBinding}"
                var="item" nodeFace="#{item.objectType}" styleClass="tree">
    
                <rich:componentControl disableDefault="false" event="oncontextmenu" for="iaContextMenu" operation="show" />
    
                <rich:treeNode id="ugNode" type="user-group" reRender="userAdminDetails" nodeSelectListener="#{userBean.expandUserGroup}">
                    <h:outputText value="#{item.name}" />
                    <rich:componentControl disableDefault="true" rendered="#{not tab}"
                        event="oncontextmenu" for="ugContextMenu" operation="show">
                        <f:param value="#{item.id}" name="selectedUserGroupId" />
                    </rich:componentControl>
                </rich:treeNode>
    
                <rich:treeNode id="iaNode" type="instance-admin" nodeSelectListener="#{userBean.expandUserGroup}">
                    <h:outputText value="#{item.name}" />
                </rich:treeNode>
    
                <rich:treeNode id="doNode" type="data-owner" nodeSelectListener="#{userBean.expandDataOwner}">
                    <h:outputText value="#{item.name}" />
                    <rich:componentControl disableDefault="true" rendered="#{not tab}"
                        event="oncontextmenu" for="doContextMenu" operation="show">
                        <f:param value="#{item.id}" name="selectedUserGroupId" />
                    </rich:componentControl>
                </rich:treeNode>
    
                <rich:treeNode id="usNode" type="user" nodeSelectListener="#{userBean.expandUser}">
                    <h:outputText value="#{item.name}" />
                </rich:treeNode>
            </rich:tree>
    
            <rich:contextMenu rendered="#{not tab}" attachTo="ugNode" id="ugContextMenu" submitMode="ajax">
                (...)
            </rich:contextMenu>
    
    

     

     

    Without the binding="#{userBean.richtreeBinding}" everything is working fine, but I need the UITree in my backing bean to expand/collapse nodes from code.

     

    But when I add the binding attribute, I get:

     

    com.sun.facelets.FaceletViewHandler handleRenderException

    FATAL: Error Rendering View[/jsf/userView.xhtml]

    java.lang.IllegalStateException: duplicate Id for a component userGroupAdminView:userAdminTreeForm:userTree:ugNode

        at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:68)

        at org.ajax4jsf.application.TreeStructureNode.apply(TreeStructureNode.java:92)

        (...)

     

    I also tried to bind the UITree to a request scoped bean, but the error is the same.