-
1. Re: RF 4: Expand tree programmatically
kwutzke Nov 24, 2011 10:52 AM (in response to captainvoid)1 of 1 people found this helpfulThis works for me:
{code}<rich:treeNode expanded="#{true}" ...>{code}
Karsten
-
2. Re: RF 4: Expand tree programmatically
bleathem Nov 24, 2011 3:30 PM (in response to kwutzke)1 of 1 people found this helpfulIndeed, using the expanded attribute seems like the only way to achieve this. Looking through the TreeNodeImpl javadoc, the expanded state is indeed not exposed. Neither is it available via the javascript API. You could fire events to expand the treeNodes, but that's getting messy.
If you would like to see a better programmatic API for toggling tree nodes, please file a feature request jira, and we'll take a closer look at it.
-
3. Re: RF 4: Expand tree programmatically
captainvoid Nov 25, 2011 8:42 AM (in response to bleathem)Thanks for the hints you gave, Karsten and Brian.
I didn't know that the "expanded" attribute in treeNode can take an EL expression (since it's not documented).
What I also found out that the EL expression needs to reference a property with getter and setter - and, toggle type being ajax, on toggling the nodes the setter is called!
So this is my solution:
I map the expanded attribute to a "expanded" property in my custom node class (extends TreeNodeImpl) with initial value "true".
So Richfaces can keep track of the expanded/collapsed state even without defining a treeToggleListener..