3 Replies Latest reply on Jun 21, 2007 5:51 AM by Alexander Belov

    Richfaces tree and conversation switching

    Tomislav Tkal?evi? Novice

      When switching between coversations in conversation list my rich tree component,who has a switch type ajax, loses it's previous state. But when submiting a page in that conversation, richfaces tree saves its state and stays in previous condition!!

      First picture link

      Second picture link

      Third picture link

        • 1. Re: Richfaces tree and conversation switching
          Alexander Belov Novice

          I have the same problem, if I don't use binding of the tree in session managed-bean.

          • 2. Re: Richfaces tree and conversation switching
            Tomislav Tkal?evi? Novice

            I can save state of the tree on this way:

            >>In jsp my tree component look's like this:

            <r:tree id="drvo" switchType="ajax" style="width:300px"
            value="#{richKatalog.data}" var="item" nodeFace="#{item.type}"

            >>My bean look's like this:

            package orka.test;

            import java.io.IOException;

            import javax.faces.component.UIComponent;
            import javax.faces.event.FacesEvent;

            import org.jboss.seam.ScopeType;
            import org.jboss.seam.annotations.In;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Out;
            import org.jboss.seam.annotations.Scope;
            import org.richfaces.component.UITree;
            import org.richfaces.component.UITreeNode;
            import org.richfaces.component.events.NodeExpandedEvent;
            import org.richfaces.component.state.TreeState;

            public class KatalogTest{

            @In @Out
            private UITree tree;

            TreeState state;

            public void ispisi(){

            try {
            } catch (IOException e) {

            public void onExpand(NodeExpandedEvent event){
            // UITree drvo = getTree(event);
            state=(TreeState) tree.getComponentState();
            // System.out.println("Node " + (drvo.isExpanded() ? "expanded" : "collapsed") + " " + drvo.getRowKey());

            public void restoreState(){
            System.err.println("Usao u restore state");

            private UITree getTree(FacesEvent event){
            UIComponent component = event.getComponent();
            if(component instanceof UITree){
            return (UITree)component;
            if(component instanceof UITreeNode){
            return (UITree)component.getParent();
            return null;

            This saves state of the tree on every expand and collapse of the node, and through the method called restore state i can restore my previous state of tree.
            But there comes again one problem...Can I somehow call a method from a pageflow...I need this because when coming back to that conversation in conversation list previous state should be restored, that is the best way because i don't want to push the button to call the action method restore state...

            • 3. Re: Richfaces tree and conversation switching
              Alexander Belov Novice

              It seems there is no API to control tree state. The problem is in TreeState class. It is not serializable and cannot be saved in session.

              If you save you bean in request scope, the state will be lost. You can save your bean in session scope and call restoreState() method in getTree() method, for example.