Hey,
I am hoping someone here can help me work out how to dynamically build a PanelMenu. I have implemented the code (in a way I think is meant to work):
DynamicMenu class:
@Name("dmenu") @AutoCreate public class DynamicMenu { private List menuItems; public List getMenuItems() { if (menuItems == null) { System.out.println("Pimping out the menu ..."); HtmlPanelMenuGroup myPanelMenuGroup = new HtmlPanelMenuGroup(); myPanelMenuGroup.setLabel("My Group"); HtmlPanelMenuItem myPanelMenuItem = new HtmlPanelMenuItem(); myPanelMenuItem.setLabel("My Item"); myPanelMenuGroup.setValue(new Object[]{myPanelMenuItem}); menuItems.add(myPanelMenuGroup); } return menuItems; } public void setMenuItems(List menuItems) { this.menuItems = menuItems; } }
<rich:panelMenu style="width:200px" iconExpandedGroup="disc" iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" rendered="#{identity.loggedIn}" binding="#{dmenu.menuItems}"/>
In JSF, if you create any active and namespace components from the java code, define the id explicitly.