-
Book Overview & Buying
-
Table Of Contents
PrimeFaces Cookbook
By :
Data components such as DataTable, Tree, and TreeTable have a special integration with the context menu. These components can display a context menu per mouse right-click on any row in DataTable or any node in Tree.
In this recipe, we will integrate a context menu with the Tree component. Integration with DataTable or TreeTable is similar and well described in the PrimeFaces User's Guide documentation of these components (http://primefaces.org/documentation.html).
We will develop a context menu with two menu items, View and Delete. A View item shows the currently selected tree node and the Delete item removes it. We would like to implement this behavior for all tree nodes. The following listing demonstrates the p:contextMenu integration with p:tree:
<p:growl id="growl" showDetail="true"/>
<p:contextMenu for="fileSystem">
<p:menuitem value="View" update="growl"
actionListener="#{contextMenuController.viewNode}"
...
Change the font size
Change margin width
Change background colour