6.87.  < rich:recursiveTreeNodesAdaptor >

6.87.1. Description

The rich:recursiveTreeNodesAdaptor provides possibility to define data models and process nodes recursively.

Expanded tree with recursive <rich:treeNodesAdaptor>

Figure 6.210. Expanded tree with recursive <rich:treeNodesAdaptor>


6.87.2. Key Features

  • Allows to define combined data models
  • Possibility to define nodes for processing via attributes
  • Allows to process nodes recursively

Table 6.415. rich : recursiveTreeNodesAdaptor attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
idEvery component may have a unique id that is automatically created if omitted
includedThis boolean expression is used to define which elements of both collections are processed
includedNodeThis boolean expression is used to define which elements are processed
includedRootThis boolean expression is used to define which elements are processed appling to "roots" collection
nodesDefines collection to use at the other (non-top) levels of iteration
renderedIf "false", this component is not rendered
rootsDefines collection to use at the top of iteration
varA request-scope attribute via which the data object for the current collection element will be used when iterating

Table 6.416. Component identification parameters

NameValue
component-typeorg.richfaces.RecursiveTreeNodesAdaptor
component-classorg.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor
component-familyorg.richfaces.RecursiveTreeNodesAdaptor
tag-classorg.richfaces.taglib.RecursiveTreeNodesAdaptorTag

6.87.3. Creating the Component with a Page Tag

To create the simplest variant of rich:recursiveTreeNodesAdaptor on a page, use the following syntax:

Example:


...
    <rich:recursiveTreeNodesAdaptor var="issue" root="#{project.root}" nodes="#{model.issues}">
        ...
        <rich:treeNode>
             <!-- node content -->
        </rich:treeNode>    
        <!-- Others nodes -->   
        ...
    </rich:recursiveTreeNodesAdaptor>
...

6.87.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor;
...
HtmlRecursiveTreeNodesAdaptor myRecursiveTreeNodesAdaptor = new HtmlRecursiveTreeNodesAdaptor();
...

6.87.5. Details of Usage

The typical variant of using:


...
<rich:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
    <rich:treeNodesAdaptor id="project" nodes="#{loaderBean.projects}" var="project">   
        <rich:treeNode>
            <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
        </rich:treeNode>
        <rich:recursiveTreeNodesAdaptor id="dir" var="dir" root="#{project.dirs}" nodes="#{dir.directories}">
            <rich:treeNode>
                <h:commandLink action="#{dir.click}" value="Directory: #{dir.name}" />
            </rich:treeNode>            
            <rich:treeNodesAdaptor id="file" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>
            <rich:treeNodesAdaptor id="file1" var="file" nodes="#{dir.files}">
                <rich:treeNode>
                    <h:commandLink action="#{file.click}" value="File1: #{file.name}" />
                </rich:treeNode>
            </rich:treeNodesAdaptor>
            <rich:recursiveTreeNodesAdaptor id="archiveEntry" var="archiveEntry"
                roots="#{dir.files}" nodes="#{archiveEntry.archiveEntries}" 
                includedRoot="#{archiveEntry.class.simpleName == 'ArchiveFile'}"
                includedNode="#{archiveEntry.class.simpleName == 'ArchiveEntry'}">      
                <rich:treeNode id="archiveEntryNode">
                    <h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
                </rich:treeNode>
            </rich:recursiveTreeNodesAdaptor>
        </rich:recursiveTreeNodesAdaptor>
    </rich:treeNodesAdaptor>
</rich:tree>
...