views:

508

answers:

1

I have a JSF page that displays a RichFaces Treeview, from a TreeNodeImpl model generated in the backing bean.

Now I want the page to display initially with a specific node expanded / selected. Preferrably this expansion should be controlled from the backing bean (no javascript wizardry)

The whole tree has been generated at the time of initialization of the backing bean

Is this possible? I have seen mentioning of TreeState, is that the way to go?

+2  A: 

<rich:tree> has a property called adviseNodeOpened (check here)

It should contain a javax.el.MethodExpression. The target method signature must match

java.lang.Boolean adviseNodeOpened(org.richfaces.component.UITree)

This is documented as:

MethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is expanded; java.lang.Boolean.FALSE, a particular treeNode is collapsed; null, a particular treeNode saves the current state

Bozho
Thank you! That worked for me. Since I only wanted it to be expanded a specific way on first load, I had to add some additional logic, but it was no problem, I just added some code that returns the value of "isExpanded()" of the method argument in that case.I also used "getRowData()" on the method argument to extract the data of the node in question.
Brummo