6 Replies Latest reply on Apr 27, 2009 10:20 AM by Marc Baum

    Problem with recursiveTreeNodesAdaptor

    Marc Baum Newbie

      Hi all,

      I took the example from the livedemo:

      <rich:tree style="width:300px" switchType="ajax" stateAdvisor="#{treeDemoStateAdvisor}">
       <rich:recursiveTreeNodesAdaptor roots="#{fileSystemBean.sourceRoots}"
       var="item" nodes="#{item.nodes}" />
       </rich:tree>


      But there there is only the root node to be openend. Every other folder is displayed as a leaf.

      Any suggestions what I could have done wrong?

      Thank,
      Marc

        • 1. Re: Problem with recursiveTreeNodesAdaptor
          Nick Belaevski Master

          Hi Marc,

          Probably, there are no child files/folders or bean is unable to read them. Can you please check that?

          • 2. Re: Problem with recursiveTreeNodesAdaptor
            Marc Baum Newbie

            Hi Nick,

            thank you for your answer. No, there are a lot of childs / folders. Even if I hard code the return of some childs they are not shown. It seems that my function getNodes() is only called in the first layer.

            If have the following structure:

            Root:
            /

            First Layer:
            /WEB-INF
            /META-INF:

            Second Layer:
            /WEB-INF/lib
            /WEB-INF/classes
            /WEB-INF/web.xml
            ....

            Third Layer:
            /WEB-INF/lib/log4j.jar
            .....

            If I debug, the function "getNodes()" is called in the Root and in the WEB-INF node but not deeper.

            Maybe there is something wrong with my environment? I am working with a Tomcat 6.

            Regards,
            Marc

            • 4. Re: Problem with recursiveTreeNodesAdaptor
              Marc Baum Newbie

              There is a strange behavior: On my notebook machine it doesn't work and on my desktop machine it works. It is the same code. I want have a dynamic loading of the child nodes. Maybe there is a problem in the hibernate part because the difference between both machines are the databases: mysql on notebook and oracle on desktop. But anyway here is the relevant code:

              JSF:

              <rich:tree id="menue" style="width:200px;max-width:400px;"
               ajaxSubmitSelection="true" switchType="ajax"
               nodeSelectListener="#{PageManager.selectNode}"
               reRender="pagePanel,pageLinkPanel" acceptedTypes="page"
               dropListener="#{PageManager.processDrop}">
               <rich:recursiveTreeNodesAdaptor roots="#{PageManager.root}"
               var="item" nodes="#{item.childList}">
               <rich:treeNode dragType="page" dragValue="#{item}"
               dragIndicator="indicator">
               <rich:dndParam name="label" value="#{item.pagetitle}" />
               <h:outputText value="#{item.pagetitle}" />
               </rich:treeNode>
               </rich:recursiveTreeNodesAdaptor>
              </rich:tree>
              

              PageManager:
              public PageManager(){
              
              private WebPage root;
              
              ....
              
              public WebPage getRoot() {
               if (root == null) {
               root = ControllerDictionary.get().getPageDao().findById(
               new Long(1), false);
               }
               return root;
              }
              }
              

              WebPage:

              public class WebPage{
              
               @Transient
               private List<WebPage> childList = null;
               @Transient
               private Calendar childReadDate = null;
              
               ...
              
               public List<WebPage> getChildList() {
               if (childList == null) {
               logger.debug("Load for Page " + this.getId());
               childList = ControllerDictionary.get().getPageDao().getChildList(
               this);
               childReadDate = Calendar.getInstance();
               for (WebPage p : childList) {
               p.setParentNode(this);
               }
               } else {
               logger.debug("Childnodes for Page " + this.getId()
               + " already loaded");
               }
               return childList;
               }
              }


              If I open the root node I can see in my log that the function getChildList is called very often, but at the object of the root node!

              So I have a lot of log entries like this:

              Childnodes for Page 1 already loaded


              But I would expect some thing like:

              Load for Page 2
              Load for Page 3
              Load for Page 4
              Load for Page 5
              ...


              Any hint?


              • 5. Re: Problem with recursiveTreeNodesAdaptor
                Nick Belaevski Master

                Hello,

                Commons-collections of 2.x version can cause the issue. Can you please check which version you are using?

                • 6. Re: Problem with recursiveTreeNodesAdaptor
                  Marc Baum Newbie

                  Nick, you are right. I got the common-collection 2.1.1 in the classpath. Now with 3.2 everything is fine.

                  Thank you very much and regards from Germany
                  Marc