MenuButton – multiple items in a popup

A menu button is a button that displays multiple menu items in a popup when it is clicked on or pressed. A popup is an absolutely positioned element (overlay) in terms of CSS.

In this recipe, we will learn the structure of p:menuButton—a JSF tag for the menuButton component.

How to do it…

The p:menuButton tag incorporates one or more menu items. The following code snippet demonstrates four menu items that send AJAX and GET requests:

<p:menuButton value="CRUD Operations" iconPos="right"> <p:menuitem value="Save" actionListener="#{menuButtonBean.save}" icon="ui-icon-disk" update="growl"/> <p:menuitem value="Update" actionListener="#{menuButtonBean.update}" icon="ui-icon-arrowrefresh-1-w" update="growl"/> <p:menuitem ...

Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.