4 Replies Latest reply on Feb 12, 2009 7:14 PM by Nick Belaevski

    recursiveTreeNodesAdaptor doesn't go past first level

    Scott Dunbar Newbie

      I've seen that some other people have had the same problem I'm having and I wondered if anyone could point me in the right direction.

      I'm attempting to use a recursiveTreeNodesAdaptor and, while the root nodes and their children render correctly nothing else does. The environment is RichFaces 3.3.0.GA, Tomcat 6.0.18, Java 1.6.0_10. I've taken out all Hibernate and other variables and have a hard-coded example that still doesn't work. I don't get the second level children nor can I "close" any of the parent nodes. Based on the code below do you have any thoughts? Is there additional debugging I could turn on to see what is happening in the recursiveTreeNodesAdaptor?

      Thanks for any help.

      <h:form>
       <rich:tree switchType="ajax" stateAdvisor="#{locationStateAdvisor}">
       <rich:recursiveTreeNodesAdaptor roots="#{locationHandler.rootNodes}" var="item" nodes="#{item.children}">
       <rich:treeNode>#{item.locationName}</rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
       </rich:tree>
      </h:form>


      Code for each node:

      import java.util.List;
      import java.util.ArrayList;
      
      public class LocationUINode
      {
       private String nodeName;
       private ArrayList<LocationUINode> children;
      
       public LocationUINode( String name )
       {
       nodeName = name;
       children = new ArrayList<LocationUINode>();
      
       if( nodeName.equals( "Root Node 1" ) )
       {
       children.add( new LocationUINode( "Child 1.1" ) );
       children.add( new LocationUINode( "Child 1.2" ) );
       }
       else if( nodeName.equals( "Root Node 2" ) )
       {
       children.add( new LocationUINode( "Child 2.1" ) );
       children.add( new LocationUINode( "Child 2.2" ) );
       }
       else if( nodeName.equals( "Child 1.1" ) )
       {
       children.add( new LocationUINode( "Child 1.1.1" ) );
       children.add( new LocationUINode( "Child 1.1.2" ) );
       }
       }
      
       public List<LocationUINode> getChildren()
       {
       // added as the example code does something similar - has no effect
       if( children == null )
       children = new ArrayList<LocationUINode>();
      
       return children;
       }
      
       public String getLocationName()
       {
       return nodeName;
       }
      }


      Code for the managed bean:
      import java.util.List;
      import java.util.ArrayList;
      
      public class LocationHandler
      {
       private ArrayList<LocationUINode> srcRoots = null;
      
       public List<LocationUINode> getRootNodes()
       {
       if( srcRoots == null )
       {
       srcRoots = new ArrayList<LocationUINode>();
       srcRoots.add( new LocationUINode( "Root Node 1" ) );
       srcRoots.add( new LocationUINode( "Root Node 2" ) );
       }
      
       return srcRoots;
       }
      }


      Any pointers or help would be greatly appreciated.