PhotoAlbum Application Download Support Developer Guide
Skins:
Resources/Beans Handling
Ajax Miscellaneous
Usage
Tag Information

Both recursiveTreeNodesAdaptor & treeNodesAdaptor (model adaptor components further in the text) components allow defining data model declaratively and binding treeNode components to tree model nodes. treeNodesAdaptor has a "nodes" attribute that's used to define a collection of elements to iterate through. Collections are allowed to include: lists, arrays, maps, XML NodeList & NamedNodeMap either as single object. The current collection element is accessible via a request-scoped variable named as "var" attribute value.

recursiveTreeNodesAdaptor is an extension of a treeNodesAdaptor component that allows you to define two different value expressions: the first, assigned by "roots" attribute is used at the top of recursion, the second "nodes" is used on another recursion levels (the second level and deeper).

Example

org

richfaces
demo
datatablescroller
datatable

treemodeladaptor




View Source


View FileSystemBean.java Source


View FileSystemNode.java Source


View PostbackPhaseListener.java Source


View TreeDemoStateAdvisor.java Source


Model adaptor components can be nested without any limitations. The following code-snippet shows an example of using Nodes Adapter along with rich:tree

Code
<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 id="pkg1" var="pkg" nodes="#{srcDir.packages}">
                <rich:treeNode>
                    <h:commandLink action="#{pkg.click}" value="Package1: #{pkg.name}" />
                </rich:treeNode>

                <rich:treeNodesAdaptor id="class1" var="class" nodes="#{pkg.classes}">
                    <rich:treeNode>
                        <h:commandLink action="#{class.click}" value="Class1: #{class.name}" />
                    </rich:treeNode>
                </rich:treeNodesAdaptor>
            </rich:treeNodesAdaptor>
        </rich:treeNodesAdaptor>
        
        <rich:recursiveTreeNodesAdaptor id="dir" var="dir"
            roots="#{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>

Data model nodes are wired to treeNode components by nesting treeNode components with a "type" attribute not defined inside model adaptor components. The first rendered one is used, or the default one if all treeNode components are non-rendered.

RichFaces Wiki RichFaces Project Site