3 Replies Latest reply on Dec 18, 2007 9:47 AM by Mikael Andersson

    How to keep the richfaces tree state across requests?

    Wu Di Newbie

      I only heard about that we can bind componentState to treeState with switchType="ajax".
      Does anyone know how to do that?
      Please help me with a few sample code both in the backing bean and JSF page.

      Thanks in advance.

        • 1. Re: How to keep the richfaces tree state across requests?
          Mikael Andersson Master

          Yeah,
          I know.

          Very simple really, just put a TreeState object in the backing bean and use the componentState" attribute of the rich:tree.

          I think you can find some more info by searching the forum, if not let me know and i'll write some code down (not at work atm, in another country).

          I still wish a richfaces developer could comment on if it is possible to preserve the tree state without using ajax switchType. Would be nice to hear from someone who knows their stuff.

          - Mike

          • 2. Re: How to keep the richfaces tree state across requests?
            Wu Di Newbie

             

            "mail.micke@gmail.com" wrote:
            Yeah,
            I know.

            Very simple really, just put a TreeState object in the backing bean and use the componentState" attribute of the rich:tree.

            I think you can find some more info by searching the forum, if not let me know and i'll write some code down (not at work atm, in another country).

            I still wish a richfaces developer could comment on if it is possible to preserve the tree state without using ajax switchType. Would be nice to hear from someone who knows their stuff.

            - Mike

            Thanks for your kind reply Mike.
            I looked for almost everywhere and can could not find that kind of code.
            Do you mind if you could share a piece of code especially in the backing bean?
            I have a clue for other switchType.
            However, I'am missing a part of the API to solve that problem.


            • 3. Re: How to keep the richfaces tree state across requests?
              Mikael Andersson Master

              Hi,

              on the backing bean :

               private TreeState treeState;
              

              + getters and setters

              XHTML :
              <rich:tree id="treeId"
               value="#{treeData}"
               switchType="#{userMenu.switchType}"
               nodeSelectListener="#{userMenu.onSelect}"
               changeExpandListener="#{userMenu.onExpand}"
               var="item"
               iconExpanded="/_graphics/_icons/bookfolderopen.gif"
               iconCollapsed="/_graphics/_icons/bookfolder.gif"
               componentState="#{userMenu.treeState}"
               nodeFace="#{item.nodeFace}">
              
              ....
              </rich:tree>
              

              The important bit being the "componentState" attribute.