4 Replies Latest reply on Nov 20, 2013 4:40 PM by amittikoo84

    How to partially update the rich:tree nodes?

    amittikoo84

      I am using a rich:tree to display a large amount of data in my application. Each node has a considerable amount of HTML along with drag and drop support for reordering.

      My problem is that when I drop a node into another, it seems that I have to re-render the whole tree. Is there a way I can chose which nodes to render. since re-order affects only certain nodes, re-rendering the whole tree seems to be unnecessary.

      <rich:tree toggleType="ajax" var="node" id="segmentTree"
         nodeClass="rich-node-class" handleClass="abc" iconClass="cde"
         labelClass="node-lbl">
         <rich:treeModelRecursiveAdaptor
         roots="#{segmentationBean.treeAsList}" nodes="#{node.children}">
         <rich:treeNode id="treeNode" styleClass="treeNode" expanded="#{node.expanded}">
      
         <rich:dropTarget acceptedTypes="segments" dropValue="#{node}"
         render="segmentTree"
         dropListener="#{segmentationBean.onSegmentReorder}"
         oncomplete="initializeTree();" />
         </a4j:outputPanel>
         </rich:treeNode>
         </rich:treeModelRecursiveAdaptor>
         </rich:tree>
      

       

      Any help would be greatly appreciated. Thanks.

        • 1. Re: How to partially update the rich:tree nodes?
          bleathem

          You'll have to file a feature request in our issue tracker for such functionality.

           

          In the mean time, make sure you aren't executing any business logic (eg. database reads) in rendering the tree nodes, caching values in your managed beans to optimize performance.

          • 2. Re: How to partially update the rich:tree nodes?
            amittikoo84

            Hello Brian,

            Thanks a lot lot the feedback. I will definitely do that. In the meanwhile I was able to jury rig my code to get the desired functionality. Here is what I had to do:

             

            <a4j:commandLink rendered="#{node.expanded}"
                             render="treeNode" execute="segmentTree"
                             oncomplete="initializeTree();">
              <h:graphicImage library="images" styleClass="collapsed"
                              name="segmentation/collapse.png" />
              <a4j:param assignTo="#{node.expanded}" value="false" />
              <f:param name="#{treeNodeBinding.clientId}__NEW_NODE_TOGGLE_STATE" value="true" />
              <f:param name="#{treeNodeBinding.clientId}__TRIGGER_NODE_AJAX_UPDATE" value="true" />
            </a4j:commandLink>
            
            

             

            The main parts of the code are the "f;params" and the execute="segmentTree"(id of my tree). Do you see any disadvantages or possible issues with this workaround?

            • 3. Re: How to partially update the rich:tree nodes?
              bleathem

              Without seeing the code in context it's hard to say.  If it's working for you, I'd say go for it!

              • 4. Re: How to partially update the rich:tree nodes?
                amittikoo84

                It seems to be working fine. And rendering the tree everytime is just not an option. My tree have around 2000 nodes with each node looking like this:

                 

                tree.jpg

                Re-rendering is very expensive. Thanks anyways and hope the workaround helps someone else.