O'Reilly logo

PrimeFaces Cookbook by Mert Çalışkan, Oleg Varaksin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Context menu with nested items

The context menu is displayed when the mouse is right-clicked. It replaces the native context menu in the browser and gives web applications a desktop-like feeling and behavior. PrimeFaces' context menu provides an overlay with submenus and menu items.

In this recipe, we will develop a context menu with nested items and see how to attach it to any component. As example, we will attach the context menu to a panel component.

How to do it...

The context menu is defined by the p:contextMenu tag. We would like to define two submenus—one with menu items having URLs (they send GET requests) and one with ajaxified menu items (they send POST requests). Ajaxified menu items perform the CRUD operations and update p:growl

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required