1 2 Previous Next 15 Replies Latest reply on Nov 10, 2008 11:00 PM by nbelaevski Go to original post
      • 15. Re: rich : tree // rich:tree // trying to make the basics wo
        nbelaevski

        Hello,

        Please excuse me for completely missing this topic. Let me add some more information here. It is a late reply, but I hope the information added will be helpful for someone new here.

        There are two ways trees can be built:

        1. Using model (org.richfaces.model.TreeNode/javax.swing.tree.TreeNode)

        This example: http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=usage shows what node types are. There are three types of nodes there: artist, album and song; each one has its own icon, but can be customized more by defining node content representation almost in the same way we do for data table cells.

        When tree component is being rendered it iterates through model nodes and renders them using one of its immediate rich:treeNode children. Data property of current model TreeNode is exposed using "var" attribute, so if for your tree var="itemData" you can then refer to that data using #{itemData}. Standard stuff of iterational component.

        Each rich:treeNode has its own type defined by "type" attribute. rich:tree has "nodeFace" attribute that is usually EL-expression. Its value is used to select particular rich:treeNode for representation (this rich:treeNode is the one that has "type" value equals to the value of "nodeFace" expression for current model node). When particular rich:treeNode is selected it is being rendered (using "var" attribute already mentioned) and then tree goes to the next model node and process repeats.


        2. Using model tags

        Currently there are two model tags that can be used to define data and representation for tree component in the same time: rich:recursiveTreeNodesAdaptor and rich:treeNodesAdaptor. Both are used to define multi-level collections-based (another container types are possible, see user guide for more information) data model that tree component understands. For adaptor tags nested rich:treeNode components do not have types; instead the first rendered rich:treeNode child of adaptor component is used.


        Adaptor tags won't provide an easy way to implement your use case so I've just added JIRA RFC: https://jira.jboss.org/jira/browse/RF-4905 for it.

        1 2 Previous Next