|
The ice:tree tag displays hierarchical data as a "tree" of branches and leaf nodes. Optionally, the tree may also display navigation controls for the dynamic expansion and collapse of branch nodes. Tree navigation events are available so that an application can respond to these events. Nodes may also support an action event that can be used to respond to user click events.
The tree component can be used in cases where a hierarchical data structure must be viewed and navigated. This component is typically used for menu-style applications, where the user selects a tree node and the application responds with an action related to the selected node.
In implementing a tree tag, the application developer must declare in the JSP a tree tag and a single treeNode tag as a child of the tree tag. The tree tag should declare the "value" attribute to be a value binding to a backing bean that will return an object that implements the javax.swing.tree.TreeModel interface. The TreeModel must contain a tree of DefaultMutableTreeNode instances. Each DefaultMutableTreeNode instance encapsultes an IceUserObject. The IceUserObject is the extension point for the application developer. If the IceUserObject does not provide sufficient state for representation of the tree's nodes, then the application developer should extend the IceUserObject and add state as required to their extension. When creating an IceUserObject, the DefaultMutableTreeNode wrapper must be provided to the constructor. Then the node's state can be set to the attributes on the IceUserObject including: text, a convenience field that will typically represent the text that will be displayed somewhere in the content facet; expanded, whether the node is expanded on its first rendering and until the user initiates a navigation event to change this value; tooltip, the text that will appear in the tooltip that appears when the user hovers over a node; leafIcon, the application-relative path to an image that will be used to represent this node when it has no children (is a leaf), typically referred to in the icon facet; branchExpandedIcon, the application-relative path to an image that will be used to represent this node when it has children (is a branch) and is expanded, typically referred to in the icon facet; branchContractedIcon, the application-relative path to an image that will be used to represent this node when it has children (is a branch) and is not expanded, typically referred to in the icon facet. The "binding" attribute can be defined so that the application developer will have access to the Tree component in the application's backing bean. The "var" attribute can be declared on the tree tag such that the treeNode tag's children have access to the state of the TreeModel's node that it represents.
Example
<ice:tree value="#{treeBean.model}" var="item" hideRootNode="#{false}" hideNavigation="#{false}" styleClass="italic">
<ice:treeNode>
<f:facet name="content">
<ice:panelGroup style="display: inline">
<ice:outputText value="#{item.userObject.text}" />
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
Rendered Output
|