A classic tree can created with the <tc:tree/>
tag.
Tobago knows two more presentations of a tree. As a
Tag Library Documentation:
The tree tag has two attributes, value
and var
. The attribute value
contain a DefaultMutableTreeNode, which represent the tree.
The var
attribute is the name of the variable, to get specific content.
<tc:tree value="#{treeController.sample}" var="node">
In every tree, a <tc:treeNode/>
has to be added.
A <tc:treeNode/>
can contain several tags to describe the node.
In this example, two tags are used.
The <tc:treeIndent/>
tag, which add an indent besides a node
and <tc:treeLabel value="\#{node.userObject.name}"/>
, which contain the
String for the label. Notice that 'node' is the value of the var
attribute from the tree tag.
An icon can be added to a node with
<tc:treeIcon value="image/feather-leaf.png" closed="image/feather-closed.png" open="image/feather-open.png"/>
.
In this case, the targeted image is 'feather-leaf.png'. It is displayed for leaf nodes.
For open or closed folder there are explicit attributes.
If these attributes are not used, defaults are used.
In this example, some boolean attributes can be activated and deactivated in the right boxes for
<tc:tree/>
and
<tc:treeIndent/>
.