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

Accessing commands via menubar


Menubar is a horizontal navigation component with drop-down menus that are displayed on mouseover or on clicking. Menubar features the same common behaviors as every PrimeFaces menu. It consists of (nested) submenus, menu items, and custom content that can be built declaratively or programmatically by modeling.

In this recipe, we will build a declarative menu bar with various commands as nested and direct menu items. The possibility of including any custom content, such as input, select, and button components, will be illustrated as well.

How to do it…

We will create a menu bar as shown in the following screenshot.

In the screenshot, the submenu Create New contains three menu items, Folder, Video File, and HTML File. The following complete code listing shows p:menubar with submenus p:submenu and menu items p:menuitem inside. An input component and a button component are included via f:facet with name="options" as well. The following code shows this:

<p:growl...