5 Replies Latest reply on Dec 21, 2010 5:08 PM by nbelaevski

    Html Component class for rich:tree

    nirvanbd

      Hi,

         What is the component class (html) representing rich:tree in Richfaces 4.0.0M4. I am trying to use rich:tree for my site navigation. I am able to use the tree but it doesn't remember its state when a different page is rendered (all nodes appear collapsed). So I was thinking to use component binding from JSF page and store tree in session scoped JSF bean.

       

      regards,

      Nirvan.

        • 1. Re: Html Component class for rich:tree
          nbelaevski

          Hi Nirvan,

           

          It's org.richfaces.component.UITree. Also JSF spec. strongly recommends against storing UI components in session-scoped beans; so just bind 'expanded' attribute of tree node to the model and store state of the tree there. 

          • 2. Re: Html Component class for rich:tree
            nirvanbd

            Hi Nick,

                      I tried to implement your suggestion, and it worked partly. I have created a boolean variable in my TreeNode class that keeps track of its expanded state. However, I am not able to set that variable because I don't know which event I can use to set that variable. I used following

            <rich:treeNode expanded="#{treeMenuBean.nodeExpanded}>     
            

            and here are the javabean methods

            public boolean isNodeExpanded(){...}
            public void setNodeExpanded{...}
            

            The problem is that isNodeExpanded() is getting called correctly, but setNodeExpanded() is not called. As a result, I am unable to set the boolean variable in my TreeNode class.

             

            regards,

            Nirvan

            • 3. Re: Html Component class for rich:tree
              nbelaevski

              Nirvan,

               

              I've remembered that there was an issue with 'expanded' attribute in M4. It should be fixed in M5, can you please try with the latest 4.0.0-SNAPSHOT?

              • 4. Re: Html Component class for rich:tree
                nirvanbd

                Nick,

                      Since I am using toggleType="client", I don't think it would be possible to use the expanded property for setting the nodes expanded. To support this I tried using toggleType="ajax" and the setter setExpandedNode(boolean expanded) gets correctly called.

                      Also, I have outputLink in the nodes that point to different xhtml pages, so the richTree component wont be restored and a new one will be created in the xhtml page identified by the outputLink clicked.

                      I seem to be stuck, although I have employed a crude fix (for temporary testing).

                 

                      Are the snapshots available as direct download? actually I am not very familiar with the maven

                 

                Thanks

                Nirvan

                • 5. Re: Html Component class for rich:tree
                  nbelaevski

                  Nirvan,

                   

                  The simplest way is to download showcase and extract RF .jar files from there: http://snapshots.jboss.org/maven2/org/richfaces/examples/richfaces-showcase/4.0.0-SNAPSHOT/.