Project Documentation

Summary

Tag name: <tr:tree>
UIComponent class: org.apache.myfaces.trinidad.component.core.data.CoreTree
Component type: org.apache.myfaces.trinidad.CoreTree

Naming container: Yes. When referring to children of this component ("partialTriggers", findComponent(), etc.), you must prefix the child's ID with this component's ID and a colon (':').

The Trinidad Tree is used to display data that is structured in a hierarchical format. This component supports multiple root elements, and it has a simple user interface (UI) - each element in the Tree is appropriately indented to indicate its level in the hierarchy, and is connected to its parent. The features of the Tree component include mechanisms for expanding and collapsing portions of the hierarchy. This component is not well suited for massive trees, since it does not support any focusing capability.

The "nodeStamp" facet of the Tree is used to display the data for each element in the tree. The "nodeStamp" is repeatedly rendered (stamped) once per element.

Code Example(s)

In the following example, the data for each element is placed under the EL property "node". The "nodeStamp" displays the data for each element by getting further properties from the "node" property:

<tr:tree var="node" value="#{myBean.orgChart.root}">
  <f:facet name="nodeStamp">
    <tr:outputText value="#{node.firstname}"/>
  </f:facet>
</tr:tree>

Supported Client Events for Client Behaviors

  • click (default)
  • dblclick
  • keydown
  • keypress
  • keyup
  • mousedown
  • mousemove
  • mouseout
  • mouseover
  • mouseup

Events

Type Phases Description
org.apache.myfaces.trinidad.event.RowDisclosureEventApply Request Values,
Invoke Application
The expansion event is generated for a table when the detail facet of a row is expanded or collapsed. For tree or a treeTable, the expansion event is generated when tree nodes are expanded or collapsed.
org.apache.myfaces.trinidad.event.SelectionEventApply Request Values,
Invoke Application
The selection event is delivered when the table selection changes.
org.apache.myfaces.trinidad.event.FocusEventApply Request Values,
Invoke Application
Event delivered when user clicks to focus on (or zoom into) a particular element's subtree of children. The TreeTable responds to this event by modifying the "focusPath" property appropriately. Subsequently, any registered FocusListener instances are called.
org.apache.myfaces.trinidad.event.AttributeChangeEventInvoke Application,
Apply Request Values
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change event might include the width of a column that supported client-side resizing.

Supported Facets

Name Description
nodeStampthe component to use to stamp each element in the tree. Only certain types of components are supported, including all components with no behavior and most components that implement the EditableValueHolder or ActionSource interfaces. In a treeTable, this must be a column.

Attributes

Name Type Supports EL? Description
attributeChangeListenerjavax.el.MethodExpressionOnly EL a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing.
bindingorg.apache.myfaces.trinidad.component.core.data.CoreTreeOnly EL an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean.
disclosedRowKeysorg.apache.myfaces.trinidad.model.RowKeySetYes the set of disclosed rows for this component. Each entry in the set is a rowKey.
focusListenerjavax.el.MethodExpressionOnly EL a method reference to a focus listener
focusRowKeyObjectYes the rowKey of the currently focused row. The rowKeys of the ancestor rows of the focus row are added to the expandedRowKeys RowKeySet by default.
idStringNo the identifier for the component. The identifier must follow a subset of the syntax allowed in HTML:
  • Must not be a zero-length String.
  • First character must be an ASCII letter (A-Za-z) or an underscore ('_').
  • Subsequent characters must be an ASCII letter or digit (A-Za-z0-9), an underscore ('_'), or a dash ('-').
immediatebooleanYes Default Value: false

whether or not data validation - client-side or server-side - should take place when events are generated by this component. When immediate is true, the default ActionListener provided by the JavaServer Faces implementation should be executed during Apply Request Values phase of the request processing lifecycle, rather than waiting until the Invoke Application phase.
initiallyExpandedbooleanYes Default Value: false

If upon initial rendering, the current subtree under the focused row path should be expanded. A RowDisclosureEvent is broadcast from the encode begin of the component so that listeners are properly notified of the disclosure.
inlineStyleStringYes the CSS styles to use for this component.
onclickStringYes an onclick Javascript handler.
ondblclickStringYes an ondblclick Javascript handler.
onkeydownStringYes an onkeydown Javascript handler.
onkeypressStringYes an onkeypress Javascript handler.
onkeyupStringYes an onkeyup Javascript handler.
onmousedownStringYes an onmousedown Javascript handler.
onmousemoveStringYes an onmousemove Javascript handler.
onmouseoutStringYes an onmouseout Javascript handler.
onmouseoverStringYes an onmouseover Javascript handler.
onmouseupStringYes an onmouseup Javascript handler.
partialTriggersString[]Yes the IDs of the components that should trigger a partial update.

This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too.

Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2"

Identifiers must account for NamingContainers. You can use a single colon to start the search from the root, or use multiple colons to move up through the NamingContainer. For example, "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), ":::" will pop out of two naming containers, etc. The search for the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the component with id = commandButton1 after popping out of two naming containers relative to this component. To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId".

renderedbooleanYes Default Value: true

whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component.
rowDisclosureListenerjavax.el.MethodExpressionOnly EL a method reference to an ExpansionListener
selectedRowKeysorg.apache.myfaces.trinidad.model.RowKeySetYes the selection state for this component.
selectionListenerjavax.el.MethodExpressionOnly EL a method reference to a selection listener
shortDescStringYes The short description of the component. This text is commonly used by user agents to display tooltip help text.
styleClassStringYes a CSS style class to use for this component.
valueObjectYes the hierarchy of tree data - must be of type org.apache.myfaces.trinidad.model.TreeModel
varStringNo Name of the EL variable used to reference each element of this collection. Once this component has completed rendering, this variable is removed (or reverted back to its previous value).
varStatusStringNo Name of the EL variable used to reference the varStatus information. Once this component has completed rendering, this variable is removed (or reverted back to its previous value). The VarStatus provides contextual information about the state of the component to EL expressions. For components that iterate, varStatus also provides loop counter information. Please see the this component's documentation for the specific properties on the varStatus. The common properties on varStatus include:
  • "model" - returns the CollectionModel for this component
  • "index" - returns the zero based row index
  • "hierarchicalIndex" - returns an array containing the row indices of heirarchy of the currrent row, for e.g. [0,1,2] Please use this attribute with caution since it requires moving currency to calculate the row index for each parent collection in the tree hierarchy.
  • "hierarchicalLabel" - returns a string label representing the hierarchy of that row, for e.g. 1.1, 1.1.1. It should be noted that the labels are 1 based vs 0 based for rowIndex. Please use this attribute with caution since it requires moving currency to calculate the row index for each parent collection in the tree hierarchy.