4 Replies Latest reply on Jul 18, 2013 10:23 AM by Paul Baker

    rich:tree doesn't fire selectionChangeListener when using selectionType="client" and toggleType="client"

    Alexander Fox Newbie

      Hi,

       

      I'm using a rich:tree component. If I set selectionType from "ajax" (which is the default) to "client", the selectionChangeListener is not invoked any more. Is this the intended behavior?

       

      <rich:tree id="naviTree" var="node" selectionType="client" toggleType="client" style="width:400px;" selectionChangeListener="#{navigationMb.nodeSelection}">
          <rich:treeModelRecursiveAdaptor id="naviTreeRecursiveAdaptor" roots="#{navigationMb.nodes}" nodes="#{node.children}">
      ...
      

       

      The documentation says:

       

      > The <rich:tree> component updates on the client side through JavaScript, without any additional requests or updates. All nodes are rendered to the client during the initial page rendering.

       

      But selectionType="client" should imho not affect the selectionChangeListener.

        • 1. Re: rich:tree doesn't fire selectionChangeListener when using selectionType="client" and toggleType="client"
          Brian Leathem Master

          The idea with selectionType="client" is that no server communication is invoked.  If you want to trigger a server communication with switchType="client", try using one of the client-side events "onselectionchange" or "onnodetoggle" and a nested a4j:ajax tag.

          1 of 1 people found this helpful
          • 2. Re: rich:tree doesn't fire selectionChangeListener when using selectionType="client" and toggleType="client"
            Andreas Wußler Newbie

            Is there a way to fire an change event WITHOUT rerendering the tree to make RequestScope usable, again???

            1 of 1 people found this helpful
            • 3. Re: rich:tree doesn't fire selectionChangeListener when using selectionType="client" and toggleType="client"
              Brian Leathem Master

              Do you mean "fire a change event" that results in a ajax/server request?  The Request Scope spans only a single ajax request, you'll have to use a longer live scope.

              • 4. Re: rich:tree doesn't fire selectionChangeListener when using selectionType="client" and toggleType="client"
                Paul Baker Apprentice

                It would help if you could post more of your tree component.  Are you executing the tree to force update when you do your function?

                 

                Consider this code here:

                 

                 

                  <rich:tree
                       id="tree"
                       nodeType="#{node.type}"
                       var="node"
                       toggleType="ajax"
                       selectionType="client">
                       <rich:treeModelRecursiveAdaptor
                           roots="#{itemCategoryController.rootCategoryNodes}"
                           nodes="#{node.children}"
                           leaf="#{node.leaf}">
                           <rich:treeNode
                               id="branchNode"
                               type="branch"
                               toggleListener="#{itemCategoryController.processTreeToggle}"
                               expanded="#{node.expanded}"
                               iconExpanded="/images/tree/Folder.gif"
                               iconCollapsed="/images/tree/Folder.gif"
                               ondblclick="processBranchSelect()">                    
                         #{node.category.categoryName}                
                           </rich:treeNode>
                           <rich:treeNode
                               id="treeNode"
                               type="leaf"
                               expanded="#{node.expanded}"
                               iconLeaf="/images/tree/Yes.gif"
                               ondblclick="#{rich:component(mnat:concat(popUpId,'PopUp'))}.hide(); processLeafSelect(); return false;"> 
                            #{node.category.categoryName}
                           </rich:treeNode>
                       </rich:treeModelRecursiveAdaptor>
                   </rich:tree>
                   
                   <a4j:jsFunction
                       name="processBranchSelect"
                       actionListener="#{branchSelectActionController[branchSelectAction]}"
                       render="tree"
                       execute="tree" />
                   <a4j:jsFunction
                       name="processLeafSelect"
                       actionListener="#{leafSelectActionController[leafSelectAction]}"
                       render="#{render}"
                       execute="tree" />
                
                

                 

                Toggling a branch will automatically fire processTreeToggle because toggleType is ajax... But if I want access to the selection when the user double clicks on a branch or leaf then I have the "execute" the tree to force the update of the selection.  See the jsFunction components. 

                 

                So in your case you have a selectionChangeListener but since you have selection type of client you are going to have to force the tree to be updated by including it in the execute phase then the selectionChangeListener will be invoked. This is my understanding and it work for me.