5 Replies Latest reply on Sep 25, 2007 1:51 PM by j-pro

    recursiveTreeNodesAdaptor demo doesn't work

    j-pro

      Good afternoon, dear RichFaces gurus!

      I've started getting into rich:tree and the first example I've tried is - Recursive Tree Adaptor (http://livedemo.exadel.com/richfaces-demo/richfaces/treeNodesAdaptor.jsf)

      I've copied the sources from the page:

      FileSystemBean.java
      FileSystemNode.java
      PostbackPhaseListener.java
      TreeDemoStateAdvisor.java

      Then I've added this in my faces-config.xml (like in 3.1.0 src):

      <managed-bean>
       <managed-bean-name>treeDemoStateAdvisor</managed-bean-name>
       <managed-bean-class>
       org.richfaces.treemodeladaptor.TreeDemoStateAdvisor
       </managed-bean-class>
       <managed-bean-scope>application</managed-bean-scope>
       </managed-bean>
      
       <managed-bean>
       <managed-bean-name>fileSystemBean</managed-bean-name>
       <managed-bean-class>
       org.richfaces.treemodeladaptor.FileSystemBean
       </managed-bean-class>
       <managed-bean-scope>application</managed-bean-scope>
       </managed-bean>
      
       <lifecycle>
       <phase-listener>org.richfaces.treemodeladaptor.PostbackPhaseListener</phase-listener>
       </lifecycle>


      Then I've added this code to my xhtml-file:
      ...
      
       <ui:define name="tree">
      
       <rich:separator height="1" style="padding:10px" />
       <h:form id="employeesDataTable_form">
      
       <rich:tree style="width:300px" switchType="ajax" stateAdvisor="#{treeDemoStateAdvisor}">
       <rich:recursiveTreeNodesAdaptor roots="#{fileSystemBean.sourceRoots}" var="item" nodes="#{item.nodes}" />
       </rich:tree>
      
       </h:form>
       <rich:separator height="1" style="padding:10px;" />
       </ui:define>
      
      ...


      And the result is no tree at all. Just free space for 400px.

      I've tried to debug FileSystemBean.getSourceRoots(), and there is a condition "if (srcRoots == null)" - it gives false. Maybe this is the reason? Because there is no defined constructor in FileSystemBean and there is no place where srcRoots equals null. Just definition: "private FileSystemNode[] srcRoots;".

      Definitely I'm doing something wrong, but what exactly?

      Thank you in advance.

        • 1. Re: recursiveTreeNodesAdaptor demo doesn't work
          j-pro

          I can't believe that nobody ever used this...

          • 2. Re: recursiveTreeNodesAdaptor demo doesn't work
            maksimkaszynski

            Bun? seara, J-Pro!
            I looked over the demo, and debugged it.
            I works, I actually cannot understand what problem you have.
            The condition you mentioned was intended to lazily initialize children of node currently opened, and it SHOULD evaluate to true, when tree node hasn't been accessed for the first time.
            After that srcRoots are populated with empty array.
            Example from tree demo populates tree from "/WEB-INF/src" folder. Do you have one?

            • 3. Re: recursiveTreeNodesAdaptor demo doesn't work
              maksimkaszynski

              Typo in prev. msg.
              and it SHOULD evaluate to true, when tree node has been accessed for the first time.

              • 4. Re: recursiveTreeNodesAdaptor demo doesn't work
                j-pro

                You're right, I had no such dir... things are easier than I thought. Sorry for bothering with such a foolish reason.

                I've found why this condition was giving false... Scope of managed beans for that tree was "application", but I run debugger not from the very first start of the app... That's why it showed:"srcRoots FileSystemNode[0] (id=342)" and bypassed the if block... getResourcePaths gave no errors. I see now.

                Sorry again for bothering, it's my fault. And thanks for your help, Maxim.


                P.S.: about "Buna seara" :) I know romanian just a little, actually I'm russian, just live here in Moldova :) I wonder where you know this language from? :)

                • 5. Re: recursiveTreeNodesAdaptor demo doesn't work
                  j-pro

                  Just wanted to ask one thing... I have this tree alongside rich:scrollableDataTable. And the width of the tree is more then 200px, which I specified in width attribude. So my nodes are just behind the dataTable... Doesn't this tree has anything like dynamically adjust it's width or something while opening new nodes?

                  Thanks