Documentation

Search 

Contents

  1. Introduction
  2. Getting Started
  3. ICEfaces Concepts
  4. Code View Support
  5. Design View Support
  6. Tag Object Toolbars
  7. Server Behaviors
  8. Property Inspectors
Selected 9. ICEfaces Tag Reference

10. ICEfaces Tag Reference

Contents > ICEfaces Tag Reference > ice:tree

ice:tree

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

Rendered ice:tree tag

Tag Attributes

action Text
 
The action attribute accepts a method-binding expression for a backing bean action method to invoke when this component is activated by the user. An action method must be a public method with no parameters that returns a String. The returned string represents the logical outcome of the action (eg. "success", "failure", etc.) and is used by the JavaServer Faces MVC framework to determine which view to display next. ICE:
actionListener Text
 
The actionListener attribute accepts a method-binding expression for a backing bean action listener method that will be notified when this component is activated by the user. An action listener method must be a public method with an javax.faces.event.ActionEvent parameter and a void return type.
binding Expression
 
The value-binding expression linking this component tag to a backing bean property.
documentImage File
 
The documentImage attribute is no longer supported by ICEfaces.
folderImage File
 
The folderImage attribute is no longer supported by ICEfaces.
folderOpenImage File
 
The folderOpenImage attribute is no longer supported by ICEfaces.
hideNavigation Boolean
 
The hideNavigation attribute is a boolean flag that when set to "true" hides navigation links.
hideRootNode Boolean
 
The hideRootNode attribute is a boolean flag that when set to "true" hides the root node.
id Text
 
The unique identifier value for this component. The value must be unique within the closest naming container.
imageDir Text
 
The imageDir attribute sets the directory location of the tree images. The default directory is /xmlhttp/css/xp/css-images/ which is include in the icefaces.jar.
immediate Boolean
 
The immediate attribute is a boolean flag indicating that component events should be sent to registered event listeners immediately rather than after the validation phase of the JSF request processing lifecycle. The immediate flag allows you bypass JSF validation for a particular component.
rendered Boolean
 
A value-binding expression that evaluates to a Boolean condition indicating if this component should be rendered.
style CSS Style
 
The style attribute sets the CSS style definition to be applied to this component when it is rendered.
styleClass CSS Class
 
The styleClass attribute sets the CSS class to apply to this component when it is rendered.
value Text
 
The value attribute sets the current value for this component.
var Text
 
The var attribute sets the name of a request-scope attribute exposing the data for each iteration over the rows in the underlying data model for this table.