TreeTable - Selection

Tree provides three selection modes, "single", "multiple" and "checkbox" in addition to the regular column based selection.

Single
NameSizeType
Multiple with metakey
NameSizeType
Checkbox
NameSizeType
<style type="text/css">
    .ui-treetable {
        margin-top: 40px
    }
    .ui-treetable table {
        table-layout: fixed
    }
    
    body .ui-button {
        margin: 10px 0 0 0;
    }
</style>


<h:form>
    <p:growl id="msgs" showDetail="true" escape="false"/>
    
    <p:treeTable value="#{ttSelectionView.root1}" var="document" selectionMode="single" selection="#{ttSelectionView.selectedNode}" style="margin-top:0">
        <f:facet name="header">
            Single
        </f:facet>
        <p:column headerText="Name">
            <h:outputText value="#{document.name}" />
        </p:column>
        <p:column headerText="Size">
            <h:outputText value="#{document.size}" />
        </p:column>
        <p:column headerText="Type">
            <h:outputText value="#{document.type}" />
        </p:column>
    </p:treeTable>
    
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
action="#{ttSelectionView.displaySelectedSingle}"/>
    
    <p:treeTable value="#{ttSelectionView.root2}" var="document" selectionMode="multiple" selection="#{ttSelectionView.selectedNodes1}">
        <f:facet name="header">
            Multiple with metakey
        </f:facet>
        <p:column headerText="Name">
            <h:outputText value="#{document.name}" />
        </p:column>
        <p:column headerText="Size">
            <h:outputText value="#{document.size}" />
        </p:column>
        <p:column headerText="Type">
            <h:outputText value="#{document.type}" />
        </p:column>
    </p:treeTable>
    
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
                     action="#{ttSelectionView.displaySelectedMultiple(ttSelectionView.selectedNodes1)}"/>
    
    <p:treeTable value="#{ttSelectionView.root3}" var="document" selectionMode="checkbox" selection="#{ttSelectionView.selectedNodes2}">
        <f:facet name="header">
            Checkbox
        </f:facet>
        <p:column headerText="Name">
            <h:outputText value="#{document.name}" />
        </p:column>
        <p:column headerText="Size">
            <h:outputText value="#{document.size}" />
        </p:column>
        <p:column headerText="Type">
            <h:outputText value="#{document.type}" />
        </p:column>
    </p:treeTable>
    
    <p:commandButton value="Display" update="msgs" icon="pi pi-clone"
action="#{ttSelectionView.displaySelectedMultiple(ttSelectionView.selectedNodes2)}"/>
</h:form>