Creates a Menu Model from a TreeModel where nodes in the treeModel contain viewId information.
Each node must have either a bean getter method or a Map property that returns a viewId. There are several restrictions on the data:
o The nodes in the tree must either be all beans or all maps, but not a mix of beans and maps. o The viewId of a node can be null, but if set it must be unique. o The tree cannot be mutable.
The getFocusRowKey method
o gets the current viewId by calling FacesContext.getCurrentInstance().getViewRoot().getViewId() o compares the current viewId with the viewId's in the viewIdFocusPathMap that was built by traversing the tree when the model was created. o returns the focus path to the node with the current viewId or null if the current viewId can't be found. o in the case where a viewId has multiple focus paths, the currently selected node is used as a key into the nodeFocusPathMap to return the correct focus path.
The Model is created by specifying it in the faces-config.xml file as follows
<managed-bean> <managed-bean-name>hr_menu</managed-bean-name> <managed-bean-class> org.apache.myfaces.trinidad.model.XMLMenuModel </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>source</property-name> <property-class>java.lang.String</property-class> <value>/WEB-INF/hr-menu.xml</value> </managed-property> </managed-bean>
@author Gary Kind