3 Replies Latest reply on Mar 19, 2007 10:04 AM by afoures

    Controlling Tree open-closed state

    dustismo

      I was wondering how to control whether a node is open or closed within my model? I.e. when the tree is first loaded I want to have some of the nodes expanded.

      Thanks,
      Dustin

        • 1. Re: Controlling Tree open-closed state
          nbelaevski

          Dustin,

          unfortunately we do not have external visual model for tree component now. I'm afraid I cannot point to any simple solution for the problem :(. Externalizing visual model, so that developers will be able to govern it, is in our TODO list as a feature of critical importance, but I cannot give any estimation on the implementation terms right now. I suppose we'll have some by Monday afternoon.

          • 2. Re: Controlling Tree open-closed state

            Hi Nick

            With the current Tree code, is it possible to extract the tree expand/collapse state so it can be stored separately and reapplied to the tree later (even without an API to modify the state)?

            The reason I need it is as follows:

            User expands tree down several levels to the node they are interested in.
            Clicking on the node starts a new Seam conversation to edit parameters and perform actions etc which may change the node text/icon etc
            Executing actions causes the TreeModel to be invalidated and reconstructed from the database ---> reconstructing the tree destroys the expand/collapse knowledge and when the user returns to the tree they have to re-navigate down to find the node again. Yuck. (The underlying tree model may also be invalidated due to external database changes beyond UI control, so we also need to be able to handle this).

            We have easily solved this issue using the Tomahawk Tree2 API by storing the view state separately in its own SFSB and using TreeModel.getTreeState()/setTreeState() to apply it to the new model once it had been recreated. This means we can keep a consistent expand/collapse state, and would seem to imply that a kind of separation between model and view is required in the tree component.

            As you can see, I don't need to know how to modify the expand/collapse state, just need a way of extracting/restoring it. Is this at all possible with the RF Tree?

            At the moment this is a real show-stopper that is preventing us from fully migrating to RichFaces. Can you please give any guidance on this?

            Many thanks,
            Scott

            • 3. Re: Controlling Tree open-closed state
              afoures