In my application, I have a tree with various object types (sources, tables, etc). I'd like to enable a context menu for the different types of object (add, delete, edit etc).
How can I use context menu on tr开发者_JS百科ee nodes in Primefaces ?
Never did it in practice (I am still on Primefaces 2.x), but from theory the facelet code should look something like this:
<h:form>
<p:tree value="#{myBean.tree}" var="node" id="tree"
selectionMode="single" selection="#{myBean.selectedNode}">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
<p:contextMenu for="tree" id="menu">
<p:menuitem value="Add" actionListener="#{myBean.add}" />
...
</p:contextMenu>
</h:form>
Usage of p:contextMenu
and p:tree
is shown in Primefaces showcase.
精彩评论