4 Replies Latest reply on Nov 11, 2008 5:11 AM by Alessio Maggiori

    reset tree state

    Jose Miguel Loor Apprentice

      Hi:

      i have an rich:tree component page; for consecutive calls to that page the component holds its state (the previous selected node is still selected)

      i need that the component state is cleared for the next call. How can i acomplish this ??

      thanks a lot

        • 1. Re: reset tree state
          sammy Jenkis Newbie

          I have a similar question: is there a way to reset a tree's selection through javascript? For example, I would like to de-select the selected tree node when the user selects an item from another list on the same page.

          For the general question of resetting the tree: I'm not sure if there is a way to have this done automatically, but this code will reset the tree expansion and selection server-side:

          public void processSelection(NodeSelectedEvent event) {
           UITree tree = (UITree) event.getComponent();
           selected = (IOrgScope) tree.getRowData();
           TreeState state = (TreeState )tree.getComponentState();
           state.setSelected(null);
           try {
           state.collapseAll(tree);
           }
           catch (IOException ex) {
           ...
           }
           }
          


          • 2. Re: reset tree state
            Nick Belaevski Master

            I've create RFC for JS tree selection API: http://jira.jboss.com/jira/browse/RF-1820. It is possible to reset selection for now using existing toggleSelection method of Tree.Item class, however that's still a hack. See ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js for more info

            • 3. Re: reset tree state
              Jose Miguel Loor Apprentice

              thanks for the help

              i had some trouble finding the component, but that is another tale :)

              i hope the "reset" method for javascript would be soon available

              if someone has an example, that would be great too

              • 4. Re: reset tree state
                Alessio Maggiori Newbie

                 

                "nbelaevski" wrote:
                I've create RFC for JS tree selection API: http://jira.jboss.com/jira/browse/RF-1820. It is possible to reset selection for now using existing toggleSelection method of Tree.Item class, however that's still a hack. See ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js for more info


                Sorry nbelaevski, could you paste some sample code showing that scripts works?

                Thanks