Skip to content

Instantly share code, notes, and snippets.

@kevindoran
Last active December 12, 2015 01:08
Show Gist options
  • Select an option

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

Select an option

Save kevindoran/4688235 to your computer and use it in GitHub Desktop.
Random menu back bean for JSF menu table
import nz.co.kevindoran.jsfmenutable.MenuTable;
import nz.co.kevindoran.jsfmenutable.Subscriber;
@ManagedBean
@ViewScoped
public class RandomMenu {
private MenuTable<Category> menuTable;
private static final int columnCount = 4;
private Category currentCategory = new Category();
public RandomMenu() {
menuTable = new MenuTable<>(columnCount);
menuTable.setContents(currentCategory.getChildCategories());
MenuClickListener menuListener = new MenuClickListener();
menuTable.addSubscriber(menuListener);
}
private class MenuClickListener implements Subscriber<Category> {
@Override
public void update(Category change) {
currentCategory = change;
menuTable.setContents(currentCategory.getChildCategories());
}
}
public MenuTable<Category> getMenuTable() {
return menuTable;
}
public Category getCurrentCategory() {
return currentCategory;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment