Search code examples
jsftreeviewrichfaces

How do I present a RichFaces tree with a specific node already expanded


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?


Solution

  • <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