3 Replies Latest reply on May 26, 2011 4:11 PM by Grzegorz Zalewski

    RF4: rich:tree does not work

    Jesper Vrelits Newbie

      Hi!

       

      I've more or less copied the tree example from the showcase:

       

      <rich:tree toggleType="ajax" var="item" >

                      <rich:treeModelRecursiveAdaptor roots="#{controller.fileSystemNode}"  nodes="#{item.directories}">

                          <rich:treeNode>

                              #{item.shortPath}

                          </rich:treeNode>

                          <rich:treeModelAdaptor nodes="#{item.files}">

                              <rich:treeNode>#{item}</rich:treeNode>

                          </rich:treeModelAdaptor>

                      </rich:treeModelRecursiveAdaptor>

                  </rich:tree>

       

      BUT it does not seem to work.

       

      I can see that controller.fileSystemNode get called alright and returns FileSystemNode which has getDirectories and getFiles (much like showcase examples).

       

      The problem however seems that nodes="#{item.directories}" resolves to NULL and therefore nothing is displayed.

       

      getDirectories of FileSystemNode is never called.

       

      Is this supposed to work. How is FileSystemNode put into "item" so that #{item.directories} will resolve?

        • 1. Re: RF4: rich:tree does not work
          Ilya Shaikovsky Master

          you should pass not just filesystemnode object but actuall roots collection.. look to sources from 3.3.x (almost the same for the 4 used)

          package org.richfaces.treemodeladaptor;

           

           

          public class FileSystemBean {

              private static String SRC_PATH = "/WEB-INF/src";

             

              private FileSystemNode[] srcRoots;

             

              public synchronized FileSystemNode[] getSourceRoots() {

                  if (srcRoots == null) {

                      srcRoots = new FileSystemNode(SRC_PATH).getNodes();

                  }

                 

                  return srcRoots;

              }

          }

          and

                          <rich:treeModelRecursiveAdaptor roots="#{FSN.roots}"  nodes="#{item.directories}">
          • 2. RF4: rich:tree does not work
            Jesper Vrelits Newbie

            Hi Ilya!

             

            Thanks. That was the cause. Not sure how I could miss that small detail.

            • 3. Re: RF4: rich:tree does not work
              Grzegorz Zalewski Newbie

              Hi,

               

              I am newby in JAVA and richfaces and I have the same problem, because in the class (in example) there is no method "getNodes".

              Could You send me code example or explain how it make work ?

               

              Thanks a lot !

               

              Kiler