Tobago Demo

Menu

Tree

The tree control displays a tree which is generated from application data. The key features are:
  • Attributes control the rendering of the tree.
  • The possibility to define the tree as "single" or "multiselect", i. e. select one or multiple nodes of the tree.
  • Editing mode for simple handling of tree structures inside the application.
Furthermore there is a TreeListbox Control, which can be described as a vertical tree. This is handy for categorization actions.

A classic tree can created with the <tc:tree/> tag. Tobago knows two more presentations of a tree. As a menu and as a list.

Tag Library Documentation: <tc:tree/> | <tc:treeNode/> | <tc:treeIndent/> | <tc:treeLabel/> | <tc:treeIcon/>

Basics

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="Node name=Category id=root" 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.

Icon

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.

Additional Attributes

In this example, some boolean attributes can be activated and deactivated in the right boxes for <tc:tree/> and <tc:treeIndent/>.

<tc:tree/>

<tc:treeIndent/>

© 2005-2023 Apache Software Foundation, Licensed under the Apache License, Version 2.0.