5 Replies Latest reply on Dec 15, 2008 3:29 PM by khisanthmagus

    recursiveTreeNodesAdaptor doesn't recurse

    khisanthmagus

      I am trying to create a tree using the recursiveTreeNodesAdaptor and a backing bean. The problem is that the tree will not expand beyond one level. I did a search and saw a few other posts about this same problem but never with any solution, or even an educated guess why it is happening. The tree is defined as

      <rich:tree var="taxonomies" showConnectingLines="true" nodeSelectListener="#{programTaxonomy.onTaxonomySelectionFromTree}" ajaxSubmitSelection="true" reRender="deleteButton,taxonomyFields">
       <rich:recursiveTreeNodesAdaptor id="taxonomy" var="taxonomy" roots="#{taxonomyAction.taxonomies}" nodes="#{taxonomy.childTaxonomies}">
       <rich:treeNode>
       <h:outputText value="#{taxonomy.code}" />
       </rich:treeNode>
       </rich:recursiveTreeNodesAdaptor>
      </rich:tree>
      


      the taxonomyAction.taxonomies returns a set of the root Taxonomy objects for the tree. Each of the Taxonomy objects contains a set of child Taxonomy objects called childTaxonomies.

      The tree correctly builds the root nodes, and the 1st level of children beneath the root nodes when the root nodes are expanded. The problem is that each of these nodes is shown as a Leaf node, which they are not.

      I am using richfaces v 3.1.5 due to limitations on the server(using OC4J).

        • 1. Re: recursiveTreeNodesAdaptor doesn't recurse
          nbelaevski

          Hi,

          Can you please add code for TaxonomyAction/Taxonomy beans and related classes?

          • 2. Re: recursiveTreeNodesAdaptor doesn't recurse
            khisanthmagus

            Sorry I didn't reply back to this...I tried doing the tree a different way which worked but suffered from severe performance issues, so I'm back to trying this.

            Relevant code from ProgramTaxonomyAction

            public Set<Taxonomy> getTaxonomies() {
             Program program = programService.getProgramByID(userBean.getCurrentProgram());
             taxonomyBean.setMode(ProgramTaxonomyBean.DISPLAY_MODE);
             return program.getTaxonomiesByType(taxonomyBean.getTaxonomyCategory());
             }


            This returns the set of the root nodes of the tree. Nothing else in that action bean is really relevant.

            TaxonomyImpl.java:
            package org.act.vsl.beans.metadata.classification;
            
            import java.util.HashSet;
            import java.util.Set;
            
            import org.act.vsl.beans.Program;
            import org.act.vsl.beans.VSLObjectImpl;
            
            public abstract class TaxonomyImpl extends VSLObjectImpl implements Taxonomy {
             private String code;
             private String description;
             private Taxonomy parent;
             private Set<Taxonomy> childTaxonomies;
             private Program program;
             private boolean isOrganize;
            
             public TaxonomyImpl() {
             }
            
             public void setCode(String code) {
             this.code = code;
             }
            
             public String getCode() {
             return code;
             }
            
             public void setDescription(String description) {
             this.description = description;
             }
            
             public String getDescription() {
             return description;
             }
            
             public void setParent(Taxonomy parent) {
             this.parent = parent;
             }
            
             public Taxonomy getParent() {
             return parent;
             }
            
             public void setChildTaxonomies(Set<Taxonomy> childTaxonomies) {
             this.childTaxonomies = childTaxonomies;
             }
            
             public Set<Taxonomy> getChildTaxonomies() {
             if (childTaxonomies == null) {
             childTaxonomies = new HashSet<Taxonomy>();
             }
             return childTaxonomies;
             }
            
             public void setProgram(Program program) {
             this.program = program;
             }
            
             public Program getProgram() {
             return this.program;
             }
            
             public void setIsOrganize(boolean isOrganize) {
             this.isOrganize = isOrganize;
             }
             public boolean getIsOrganize() {
             return isOrganize;
             }
            }



            • 3. Re: recursiveTreeNodesAdaptor doesn't recurse
              khisanthmagus

              Is there any chance that the child nodes being lazy loaded by hibernate could be the problem? I don't see HOW it could be the problem, but it is the only thing I can think of.

              • 4. Re: recursiveTreeNodesAdaptor doesn't recurse
                khisanthmagus

                Apparently that isn't it either. I turned off lazy loading of the taxonomy children and tested with a smaller tree and it still would not go any deeper.

                The tree I tested it with has a very simple structure:
                Content 1-1
                |- Content 1-2
                |- Content 1-3
                |- Content 1-4
                |- Content 1-5

                It will display content 1-1 fine, but then displays content 1-2 as a leaf node.

                • 5. Re: recursiveTreeNodesAdaptor doesn't recurse
                  khisanthmagus

                  Apparently this had something to do with the server I was using. This problem happens when I run the application through JDeveloper, but when I deploy the app to a regular OC4J container it works normally.