Horizontal Tree - Selection

Tree provides three selection modes, "single", "multiple" and "checkbox".

Single

Files

Multiple with metakey

Files

Checkbox

Files
<style type="text/css">
    .ui-button {
        margin-top: 10px
    }
</style>


<h:form>
    <p:growl id="msgs" showDetail="true" escape="false"/>
    
    <h3 style="margin-top:0">Single</h3>
    <p:tree value="#{treeSelectionView.root1}" var="doc" orientation="horizontal"
						selectionMode="single"
						selection="#{treeSelectionView.selectedNode}">
        <p:treeNode expandedIcon="pi pi-folder-open" collapsedIcon="pi pi-folder">
            <h:outputText value="#{doc.name}"/>
        </p:treeNode>
        <p:treeNode type="document" icon="pi pi-file">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="picture" icon="pi pi-image">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="mp3" icon="pi pi-video">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
    </p:tree>
				
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
action="#{treeSelectionView.displaySelectedSingle}"/>
    
    <h3>Multiple with metakey</h3>
    <p:tree value="#{treeSelectionView.root2}" var="doc" orientation="horizontal"
						selectionMode="multiple"
						selection="#{treeSelectionView.selectedNodes1}">
        <p:treeNode expandedIcon="pi pi-folder-open" collapsedIcon="pi pi-folder">
            <h:outputText value="#{doc.name}"/>
        </p:treeNode>
        <p:treeNode type="document" icon="pi pi-file">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="picture" icon="pi pi-image">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="mp3" icon="pi pi-video">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
    </p:tree>
				
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
                action="#{treeSelectionView.displaySelectedMultiple(treeSelectionView.selectedNodes1)}"/>
    
    <h3>Checkbox</h3>
    <p:tree value="#{treeSelectionView.root3}" var="doc" orientation="horizontal"
						selectionMode="checkbox"
						selection="#{treeSelectionView.selectedNodes2}">
        <p:treeNode icon="pi pi-paperclip">
            <h:outputText value="#{doc.name}"/>
        </p:treeNode>
        <p:treeNode type="document" icon="pi pi-file">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="picture" icon="pi pi-image">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
        <p:treeNode type="mp3" icon="pi pi-video">
            <h:outputText value="#{doc.name}" />
        </p:treeNode>
    </p:tree>
				
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
                action="#{treeSelectionView.displaySelectedMultiple(treeSelectionView.selectedNodes2)}"/>
</h:form>