6.90.  < rich:treeNodesAdaptor >

6.90.1. Description

The <rich:treeNodesAdaptor> provides the possibility to define data models and create representations for them.

Expanded tree with <rich:treeNodesAdaptor>

Figure 6.258. Expanded tree with <rich:treeNodesAdaptor>


6.90.2. Key Features

  • Allows to define combined data models

  • Possibility to define nodes for processing via attributes

Table 6.484. rich : treeNodesAdaptor 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
includedNodeThis boolean expression is used to define which elements are processed
nodesDefines collection to use at the other (non-top) levels of iteration
renderedIf "false", this component is not rendered
varA request-scope attribute via which the data object for the current collection element will be used when iterating

Table 6.485. Component identification parameters

NameValue
component-typeorg.richfaces.TreeNodesAdaptor
component-classorg.richfaces.component.html.HtmlTreeNodesAdaptor
component-familyorg.richfaces.TreeNodesAdaptor
tag-classorg.richfaces.taglib.TreeNodesAdaptorTag

6.90.3. Creating the Component with a Page Tag

Example:


...
<rich:treeNodesAdaptor var="issue" nodes="#{model.issues}">
    <rich:treeNode>
        <h:commandLink action="#{project.click}" value="Project: #{project.name}" />
    </rich:treeNode>
    ... 
    <!-- Others nodes -->                           
    ...
</rich:treeNodesAdaptor>
...

6.90.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlTreeNodesAdaptor;
...
HtmlTreeNodesAdaptor myTreeNodesAdaptor = new HtmlTreeNodesAdaptor();
...

6.90.5. Details of Usage

The <rich:treeNodesAdaptor> component has a "nodes" attribute that defines a collection of elements to iterate through.

Collections are allowed to include lists, arrays, maps, XML NodeList and NamedNodeMap either as a single object.

The "var" attribute is used to access to the current collection element.

The <rich:treeNodesAdaptor> component can be nested without any limitations. See the following example.

Example:


...
<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:treeNodesAdaptor id="srcDir" var="srcDir" nodes="#{project.srcDirs}">
        <rich:treeNode>
            <h:commandLink action="#{srcDir.click}" value="Source directory: #{srcDir.name}" />
        </rich:treeNode>
    <rich:treeNodesAdaptor id="pkg" var="pkg" nodes="#{srcDir.packages}">
        <rich:treeNode>
            <h:commandLink action="#{pkg.click}" value="Package: #{pkg.name}" />
        </rich:treeNode>
    <rich:treeNodesAdaptor id="class" var="class" nodes="#{pkg.classes}">
        <rich:treeNode>
            <h:commandLink action="#{class.click}" value="Class: #{class.name}" />
        </rich:treeNode>
    </rich:treeNodesAdaptor>    
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
</rich:tree>
...

6.90.6. Relevant Resources Links

Here you can see the example of <rich:treeNodesAdaptor > usage and sources for the given example.