Book Image

Primefaces Cookbook Second Edition

Book Image

Primefaces Cookbook Second Edition

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 value="Delete"
    actionListener="#{menuButtonBean.delete}"
    icon="ui-icon-close" update="growl"/>
  <p:separator/>
  <p:menuitem value="PrimeFaces" url="http://primefaces.org"/>...