2 Replies Latest reply on Jul 23, 2008 6:46 PM by Jason Gould

    recursivetreenodesadaptor subnode navigation

    nils verheyen Newbie

      Hi,

      lately I have a big problem with subnavigation in a richtree. In the tree the top navigation level is correctly rendered, but when i want to access deeper levels, the second level only contains leafs. I'm working with richfaces 3.1.6 and Hibernate3. When I expand one of the rootnodes, the method for getting the subnodes of the rootnode is executed several times (exactly 2 times more than size of the subnodelist). But to display the subnodes as folder or leaf you have to know the subnodes of the subnode and these requests are not happening.

      jsp:

      <rich:tree switchType="server">
       <rich:recursiveTreeNodesAdaptor
       roots="#{controller.treeNodes}"
       nodes="#{node.nodes}" var="node">
       <rich:treeNode>
       <a4j:htmlCommandLink
       action="#{controller.selectKodierung}">
       <h:outputText value="#{node}" />
       </a4j:htmlCommandLink>
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      


      controller:
      ...
      private List<KodierungNode> rootTreeNodes;
      ...
      public synchronized List<KodierungNode> getTreeNodes() {
       if (rootTreeNodes == null) {
       rootTreeNodes = new KodierungNode(RootService.getInstance()
       .getRootKodierung(getMandant())).getNodes();
       } else {
       System.out.println("controller.getTreeNodes()");
       }
       return rootTreeNodes;
      }
      ...
      


      KodierungNode:
      public class KodierungNode {
      
       private static List<KodierungNode> KINDER_VERSTECKT =
       new ArrayList<KodierungNode>();
      
       private List<KodierungNode> kinder;
      
       private Kodierung kodierung;
      
       public KodierungNode(Kodierung kodierung) {
       this.kodierung = kodierung;
       }
      
       public synchronized List<KodierungNode> getNodes() {
      
       System.out.println("KodierungNode.getNodes() " + kodierung.getName());
       if (kinder == null) {
      
       List<Kodierung> kinderListe = kodierung.getKindKodierungList();
      
       if (!kinderListe.isEmpty()) {
       kinder = new ArrayList<KodierungNode>();
       for (Kodierung k : kinderListe) {
       kinder.add(new KodierungNode(k));
       }
       } else {
       System.out.println("--- kinder versteckt ---");
       kinder = KINDER_VERSTECKT;
       }
       }
       return kinder;
       }
      
       public String toString() {
       return kodierung.getName();
       }
      
      }
      


      This drives me nuts ... pls help

      Thanks