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

PanelMenu – hybrid of accordion and tree


A panel menu is a hybrid of the accordion and tree components used for navigation and action. It renders a vertical menu structure with support for nested menu items.

In this recipe, we will develop a panel menu with three top submenus acting as accordion tabs and nested menu items with a tree-like look and feel.

How to do it…

A panel menu is rendered by the p:panelMenu tag. Top-level submenus define accordion-like tabs. A click on such a tab expands or collapses the subordinated content. The menu structure is similar to every PrimeFaces' menu component—it consists of submenus and menu items. Menu items can call actions, action listeners, or trigger navigations. The following code shows this:

<p:panelMenu style="width:200px">
  <p:submenu label="Ajax Operations">
    <p:menuitem value="Save"
      actionListener="#{panelMenuBean.save}"
      icon="ui-icon-disk"/>
    <p:menuitem value="Update"
      actionListener="#{panelMenuBean...