Hello,
we are trying to use panelMenu as a navigation menu for our pages, similar to the Live Demo Site.
So we need to keep the selected item between requests. Thats not difficult, we're using the following code:
<h:form>
<rich:panelMenu id="#{mainMenu.menuId()}"
expandSingle="true"
selectedChild="#{mainMenu.currentItemId}" >
<rich:panelMenuGroup name="g1" expanded="true" label="Group 1">
<rich:panelMenuItem name="g1:i1" label="Item1"
action="#{mainMenu.activateView('/testViewG1I1.xhtml','g1:i1')}" />
<rich:panelMenuItem name="g1:i2" label="Item2"
action="#{mainMenu.activateView('/testViewG1I2.xhtml','g1:i2')}" />
</rich:panelMenuGroup>
<rich:panelMenuGroup name="g2" expanded="true" label="Group 2">
<rich:panelMenuItem name="g2:i1" label="Item1"
action="#{mainMenu.activateView('/testViewG2I1.xhtml','g2:i1')}" />
...
</rich:panelMenuGroup>
</rich:panelMenu>
</h:form>
@Name("mainMenu")
@Scope(ScopeType.SESSION)
public class MainMenu {
private String currentItemId;
private static final String MENU_ID = "mainMenu";
public String getMenuId() {
return MENU_ID;
}
public String activateView(String AViewName, String AItemId) {
setCurrentId(AItemId);
return AViewName;
}
public String getCurrentId() {
return currentItemId;
}
public void setCurrentId( String ACurrentId ) {
currentItemId = ACurrentId;
}
}
yes you should care about expanded yourself in the same manner as for selected.
code from livedemo site available from our samples in svn ;)