开发者

Primefaces 3.0 : TreeNode and ContextMenu

开发者 https://www.devze.com 2023-03-17 20:50 出处:网络
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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号