Skip to content

Instantly share code, notes, and snippets.

@kevindoran
Created February 1, 2013 02:57
Show Gist options
  • Select an option

  • Save kevindoran/4688813 to your computer and use it in GitHub Desktop.

Select an option

Save kevindoran/4688813 to your computer and use it in GitHub Desktop.
Random menu back bean- primefaces version.
@ManagedBean
@ViewScoped
public class RandomMenu2 {
private MenuModel<Category> menuModel;
private Category currentCategory = new Category();
public RandomMenu2() {
menuModel = new MenuModel<>();
menuModel.setContents(currentCategory.getChildCategories());
MenuClickListener menuListener = new MenuClickListener();
menuModel.addSubscriber(menuListener);
}
private class MenuClickListener implements Subscriber<Category> {
@Override
public void update(Category change) {
currentCategory = change;
menuModel.setContents(currentCategory.getChildCategories());
}
}
public MenuModel<Category> getMenuModel() {
return menuModel;
}
public Category getCurrentCategory() {
return currentCategory;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment