2 Replies Latest reply on Mar 26, 2007 11:26 AM by Steven De Groote

    rich:Tree remains empty

    Steven De Groote Newbie

      Hi all,
      I'm new to the rich:Tree component but I cannot fill it up.
      I made a DirectoryTree class that implements the TreeNode interface.

      In my backing bean, I have this method to provide the elements for the tree:

       public DirectoryTree getDirectories()
       {
       if (dirs == null)
       {
       getLog().debug("List directories in " + downloadPath);
       dirs = new DirectoryTree(downloadPath);
       getLog().debug("The build directory tree is : " + dirs.getChildren().next());
       }
      
       return dirs;
       }
      


      Because of de logging, I'm sure the dirs variable has at least one child node. However, with this in my jsp:

       <h:form id="browser">
       <rich:tree id="dirs" style="border: 2px solid black; width: 300px; height: 300px" switchType="client" var="item" value="#{publicDownload.directories}" nodeFace="dir">
       <rich:treeNode type="dir">
       <h:outputText value="#{item.name}"/>
       </rich:treeNode>
       </rich:tree>
       </h:form>
      


      Could anyone help me out here?
      Thank you

        • 1. Re: rich:Tree remains empty
          Nick Belaevski Master

          Hello!

          Tree component handles children of the root node, not the node itself in order to have several top-level nodes. Maybe that's the case?

          You can use TreeNodeImpl as that fake root node. Just create the new one and add yours under any key.

          • 2. Re: rich:Tree remains empty
            Steven De Groote Newbie

            Thank you,
            could be something like it as just creating 2 TreeNodeImpl and making them parent and child renders me one node.

            However, I can't seem to wrap my DirectoryTree in such a TreeNodeImpl as I get a class cast exception:

            javax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Error getting property 'directories' from bean of type be.sofico.extranet.dynamic.files.PublicDownload: java.lang.ClassCastException: org.richfaces.component.TreeNodeImpl
            at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:190)
            at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
            at javax.faces.component.UIData.getValue(UIData.java:547)
            at org.richfaces.component.UITree.createDataModel(UITree.java:477)
            at org.ajax4jsf.ajax.repeat.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:464)
            at org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:280)
            at org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:265)

            It happens with:

            TreeNodeImpl tn = new TreeNodeImpl();
            tn.addChild("sqdfqqsddgrfgtggzqshyhyaez", dirs);

            It's probably the object identifier which is the problem, I chose a random string since I'm not sure what to put there ;)

            Any ideas?