O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating MenuButton

Let us see how we can create MenuButton declaratively, by performing the following steps:

  1. 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:

    Time for action – creating MenuButton
  2. We can also build the same the MenuButton component programmatically as follows:
    <p:menuButton value="Administration" model="#{menuController.menuButtonModel}" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required