the getter of the TreeState is imho the wrong place to capture the selection.
this should be done in the action method werd the result is stored.
the way you do this is ok, but you will get the selection before
rendering, not the one after submitting the page.
2006/12/20, Wong, Emmanuel (Sam) <[EMAIL PROTECTED]>:
Now, it display the checkbox on the tree that was being selected, but
when I unchecked one of the leafs or event try to resaving it. The
treestate never get never pick up the leafs that was being checked. Am
I doing something wrong? This is how I tried to capture? Thanks.
/**
* @return the _selectedCategories
*/
public TreeState getSelectedCategories() {
Set<DefaultMutableTreeNode> selection =
_selectedCategories
.getSelection();
boolean empty = selection.isEmpty();
if (!empty) {
_categoriesSelection.addAll(selection);
}
return _selectedCategories;
}
-----Original Message-----
From: Volker Weber [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 20, 2006 7:52 AM
To: MyFaces Discussion
Subject: Re: Display tobago selectable tree
Hi,
just add all nodes which should displayed as selected to the selected
set in the treeState:
selectedTrees.getSelection().add(node);
Regards,
Volker
2006/12/8, Wong, Emmanuel (Sam) <[EMAIL PROTECTED]>:
> Hi:
> Is there a way you could able to display back what you have
> saved in the database by indicate a checkmark on the Tobago tree? I
> have set the selectable="multiLeafOnly". When user selected the leafs
> that would like to save it in the database, then user retrieve back
the
> selected leafs and display with a check mark as indicated the leafs
was
> what he saved last time. Later user could de-selected the check box
for
> removing the existing leaf? Htanks.
>
>
> <tc:tree value="#{Controller.Tree}"
> state="#{Controller.selectedTrees}"
> id="Tree" idReference="userObject.id"
> nameReference="userObject.name" showIcons="true"
> showJunctions="true"
> showRootJunction="true" showRoot="true"
>
> selectable="multiLeafOnly"
> mutable="false">
> </tc:tree>
>
>
>