Tree - ContextMenu ContextMenu has special integration with Tree. Even different menus can be assigned to different node types by matching node types.
<h:form>
    <p:growl id="messages" showDetail="true" />

    <p:tree id="docs" value="#{treeContextMenuView.root}" var="doc" selectionMode="single" selection="#{treeContextMenuView.selectedNode}" dynamic="true">                    
        <p:treeNode expandedIcon="ui-icon-folder-open" collapsedIcon="ui-icon-folder-collapsed">
            <h:outputText value="#{doc.name}"/>
        </p:treeNode>
        <p:treeNode type="document" icon="ui-icon-document">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="picture" icon="ui-icon-image">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="mp3" icon="ui-icon-video">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
    </p:tree>

    <p:contextMenu for="docs">
        <p:menuitem value="View" update="messages" actionListener="#{treeContextMenuView.displaySelectedSingle}" icon="ui-icon-search" />
        <p:menuitem value="Delete" update="docs" actionListener="#{treeContextMenuView.deleteNode}" icon="ui-icon-close"/>
    </p:contextMenu>
</h:form>
                
PrimeTek, Copyright © 2017
All rights reserved.
Running PrimeFaces-6.2-SNAPSHOT on Mojarra-2.3.2.