Tree - Checkbox Selection

Node selection is a built-in feature and support three different modes, "single", "multiple" and "checkbox.

Source

<h:form>

    <p:growl id="messages" showDetail="true" escape="false"/>

    <p:tree value="#{treeCheckboxBean.root2}" var="node"
            selectionMode="checkbox"
            selection="#{treeCheckboxBean.selectedNodes}">

        <p:treeNode>
            <h:outputText value="#{node}" />
        </p:treeNode>
    </p:tree>

    <p:commandButton value="Display Selected" update="messages" style="margin:20px 0 20px 0;"
                    actionListener="#{treeCheckboxBean.displaySelectedMultiple}" id="btnDisplay"/>

</h:form>