You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Bertrand, Shawn R" <sh...@tycoelectronics.com> on 2007/05/08 18:35:47 UTC

[Trinidad] Setting initial expanded state in tree

I'd like to set the initial expanded state in my tree such that only the
top-level root node is expanded.  In my case, there is only one root
node and it may have one or more child nodes.

 

I thought the following would do it, but the second call to getKeySet()
on the PathSet object returns null:

 

// Collapse all nodes

CoreTree tree = getTree();

tree.getTreeState().getKeySet().clear();

 

// Add the first (top-level) node to the current path 

ArrayList<String> path = new ArrayList<String>();

path.add(new String("0"));

tree.getTreeState().getKeySet().add(path);

 

What is wrong with this technique?

 

Thanks in advance,

 

Shawn Bertrand

Tyco Electronics

 

 


Re: [Trinidad] Setting initial expanded state in tree

Posted by Ayhan Güngör <ag...@gmail.com>.
this should do what you want;

// Collapse all nodes
CoreTree tree = getTree();
tree.getTreeState().getKeySet().clear();

// Add the first (top-level) node to the current path
ArrayList<String> path = new ArrayList<String>();
path.add("0");
PathSet rootPathSet = new PathSet();
rootPathSet.getKeySet().add(path);
tree.setTreeState(rootPathSet);


AG


On 5/8/07, Bertrand, Shawn R <sh...@tycoelectronics.com> wrote:
>
>  I'd like to set the initial expanded state in my tree such that only the
> top-level root node is expanded.  In my case, there is only one root node
> and it may have one or more child nodes.
>
>
>
> I thought the following would do it, but the second call to getKeySet() on
> the PathSet object returns null:
>
>
>
> // Collapse all nodes
>
> CoreTree tree = getTree();
>
> tree.getTreeState().getKeySet().clear();
>
>
>
> // Add the first (top-level) node to the current path
>
> ArrayList<String> path = new ArrayList<String>();
>
> path.add(new String("0"));
>
> tree.getTreeState().getKeySet().add(path);
>
>
>
> What is wrong with this technique?
>
>
>
> Thanks in advance,
>
>
>
> Shawn Bertrand
>
> Tyco Electronics
>
>
>
>
>