I am building a dynamic menu for a menubar using the menu model and would like each menuItem to navigate to a URL and pass a parameter. The menuModel is constructed in an application-scoped backing bean, whose purpose is to construct the menu model and direct selections to the appropriate page.
Code: Select all
@ManagedBean
@ApplicationScoped
public class MenuBacking {
private MenuModel menuModel;
@EJB
ProductCategoryFacade categoryFacade;
public MenuBacking() {
menuModel = null;
}
public MenuModel getMenuModel() {
return menuModel;
}
@PostConstruct
public void BuildMenu() {
Submenu submenu = null;
MenuItem menuItem = null;
List<ProductCategory> categoryList;
menuModel = new DefaultMenuModel();
submenu = new Submenu();
submenu.setLabel("Category");
categoryList = categoryFacade.findAll();
for (ProductCategory category : categoryList) {
menuItem = new MenuItem();
menuItem.setValue(category.getCategoryName());
menuItem.setUrl("category");
submenu.getChildren().add(menuItem);
}
}
I attempted to use the Flash to store the category ID but came up against the unpleasant "JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash." problem.
Any recomendations?
Kevin
PrimeFaces 2.2
Mojarrra 2.0.2 FCS b10
GlassFish 3.0.1