Time for action – creating MenuButton
Let us see how we can create MenuButton declaratively, by performing the following steps:
- Create the MenuButton component using
<p:menuButton>
:<p:menuButton value="Administration"> <p:menuitem value="View Users" actionListener="#{menuController.showUserManagement()}"/> <p:menuitem value="Tag Management" outcome="menuButton"/> <p:menuitem value="System Config" url="menuButton.jsf"/> </p:menuButton>
The preceding MenuButton component will be rendered as shown in the following screenshot:
- We can also build the same the MenuButton component programmatically as follows:
<p:menuButton value="Administration" model="#{menuController.menuButtonModel}"></p:menuButton>
- Create
menuButtonModel
, which is an instance of typeorg.primefaces.model.MenuModel
:public MenuModel getMenuButtonModel() { MenuModel menuButtonModel...