Accessing commands via Menubar
Menubar
is a horizontal navigation component with drop-down menus that are displayed on mouse over or on clicking. Menubar
features the same common behaviors as every PrimeFaces' menu. It consists of (nested) submenus and menu items that can be built declaratively or programmatically by model.
In this recipe, we will build a declarative menu bar with various commands as nested and direct menu items.
How to do it...
We will create a menu bar as shown in the following screenshot:
The following complete code listing shows p:menubar
with submenus p:submenu
and menu items p:menuitem
inside. For instance, the submenu Create New contains three menu items, Folder, Video File, and HTML File.
<p:growl id="growl"/> <p:menubar> <p:submenu label="File" icon="ui-icon-document"> <p:submenu label="Create New"> <p:menuitem value="Folder" actionListener= "#{menubarController.createFolder}" icon="ui-icon-folder-collapsed" update...