I would like to read menu options programmatically from a database and render them using the Richfaces Html Menus.
I'm able to read in the menu options, load them into new HtmlDropDownMenu objects along with any sub-option children HtmlMenuItems and return the List.
How would I render such a List in the JSF page using <ui:repeat> ?
When I use
JSF Code:
<ui:repeat value="#{menuBean.dropDownMenus}" var="ddMenu">
<rich:dropDownMenu value="#{ddMenu.value}"/>
</ui:repeat>
Java managed bean:
public List<HtmlDropDownMenu> getDropDownMenus() {
List<HtmlDropDownMenu>menus = new ArrayList();
(load menus from database)
HtmlDropDownMenu menu = null;
Iterator iter = menus.iterator();
while (iter.hasNext()) {
menu = iter.next();
(Determine if sub-options exist and if so add them)
HtmlMenuItem menuItem = new HtmlMenuItem();
String subOption = "subOption";
menuItem.setValue(subOption);
menu.getChildren().add(menuItem);
menus.add(menu)
}
return menus;
}
I can see the HtmlDropDownMenu values but the children HtmlMenuItems do not appear.
When I return a single HtmlDropDownMenu from the managed bean like this:
<rich:dropDownMenu binding="#{menuBean.testDropDownMenu}">
</rich:dropDownMenu>
public HtmlDropDownMenu getTestDropDownMenu() {
HtmlDropDownMenu menu = new HtmlDropDownMenu();
menu.setStyle("border:1px solid #BCD1FF");
menu.setDirection("bottom-right");
menu.setJointPoint("tr");
menu.setValue("Home: Manual");
HtmlMenuItem menuItem = new HtmlMenuItem();
String subOption = "subOption";
menuItem.setValue(subOption);
menu.getChildren().add(menuItem);
return menu;
}
, it works correctly; i.e. the children options get rendered.
Whether I use binding or value in the <ui:repeat> does not render the sub-options.
Any thoughts are greatly appreciated.
Thanks