Stephan
Stephan

Reputation: 43053

Primefaces 3.0 : TreeNode and ContextMenu

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 tree nodes in Primefaces ?

Upvotes: 0

Views: 2928

Answers (1)

Matt Handy
Matt Handy

Reputation: 30025

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.

Upvotes: 1

Related Questions