A tree consisting of content from a com.webmethods.caf.faces.data.tree.ITreeContentProvider
object. An ITreeContentProvider
creates a flattened view of the tree, iterating over the tree structure in depth-first order. You can choose to use a custom ITreeContentProvider
. The Composite Application Framework library provides the following providers that you can use with tree data:
com.webmethods.caf.faces.data.tree.object.NodeTreeContentProvider
com.webmethods.caf.faces.data.tree.object.ListTreeContentProvider
NodeTreeContentProvider
The NodeTreeContentProvider
works with tree data that is in the form of a tree object model such as data in an XML document loaded into a W3C DOM tree. You need to provide the NodeTreeContentProvider
with a data model that implements the com.webmethods.caf.faces.data.tree.INode
interface, and the NodeTreeContentProvider
handles the rest.
The com.webmethods.caf.faces.data.tree.object.XMLDOMNode
class is an INode that wraps a W3C DOM tree object model. You can instantiate the INode with the DOM node that serves as the root of the tree, and an XPath string that specifies a unique ID for each node. For example, with the following XML, use the uri attribute of each node for a unique ID:
<folder name='Root Folder' uri='/folders/'>
<folder name='System' uri='/folders/system/'>
...
</folder>
<folder name='Public Folders' uri='/folders/public/'>
...
</folder>
<folder name='Users' uri='/folders/users/'>
...
</folder>
</folder>
Use the XMLUtil.loadDocumentFromString()
static utility method to load an XML document into a W3C DOM tree. Create an XMLDOMNode tree model using the document's root element as the tree model root, and using the uri attribute as each node's unique ID. With the INode tree model, you can instantiate a NodeTreeContentProvider
. The tree control uses the ITreeContentProvider
when you configure the control's value
property.
org.w3c.dom.Document doc =
com.webmethods.caf.common.XMLUtil.loadDocumentFromString(xml);
INode root = new XMLDOMNode(doc.getDocumentElement(), "@uri");
ITreeContentProvider tree = new NodeTreeContentProvider(root);
ListTreeContentProvider
The ListTreeContentProvider
works with tree data in the form of a list of rows, where each row has a property that identifies the parent of the row or the children of the row. Tree data stored in a relational database can take this parent/child form. You need to supply the ListTreeContentProvider
with the list of rows, a ValueBinding expression that specifies a unique ID for each row, and a ValueBinding expression that specifies the parent ID for each row, or a ValueBinding expression that specifies a list of child IDs for
each row.
In the following example, the row data is simply a list of String arrays. The first item in each String array is the row's parent ID, specified using a ValueBinding expression #{row[0]}
). Rows where the parent ID is null are displayed as roots. The second item in each String array is the row's unique ID, specified using a ValueBinding expression #{row[1]}
. The example below shows that in the first row, alice has two children, albert and agnes.
java.util.List list = java.util.Arrays.asList(new Object[] {
new Object[] {null,"alice","apple","astros"},
new Object[] {null,"bob","banana","brewers"},
new Object[] {null,"carla","cantaloupe","cubs"},
new Object[] {null,"dirk","dingleberries","dodgers"},
new Object[] {null,"edna","eggplant","expos"},
new Object[] {null,"frank","fruitcake","phillies"},
new Object[] {"alice","albert","pineapple","texans"},
new Object[] {"alice","agnes","cranapple","stars"},
new Object[] {"bob","bertha","banan-o-rama","packers"},
new Object[] {"bob","bradley","banana split","badgers"},
new Object[] {"frank","felicity","fruit fly","eagles"},
new Object[] {"frank","fredrick","fruitful","flyers"},
new Object[] {"frank","fanny","fruition","76ers"},
});
ITreeContentProvider tree = new ListTreeContentProvider(list,
"#{row[1]}", "#{row[0]}", null);
Columns
You can add columns to the Tree control to display content for each tree row. Table columns, including special columns, like Select Row columns, work in Trees exactly the same as they do in Tables. Additionally, the Tree Toggle column controls allow users to toggle tree rows expanded and collapsed. Usually, each tree should include a Tree Toggle control.
You can sort columns by specifying a key using the column's sort
property value. For more information, see the Standard Column control.
Children
javax.faces.Column
, Basic Column control
Info | Value |
---|---|
Component Type | com.webmethods.caf.faces.tree.Tree |
Handler Class | com.webmethods.caf.faces.component.DynamicControlHandler |
Renderer Type | com.webmethods.caf.faces.tree.Tree |
Description | Displays data model as tree |
Palette Location | CAF Html/Control/Table/Tree |
Client-Side Model | CAF.Tree.Model |
Name | Description |
---|---|
caption | Table caption |
header | Table header |
footer | Table footer |
empty | Empty message content |
Name | Required | Type | Description |
---|---|---|---|
bgcolor | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| The background color for all table cells |
border | false | javax.el.ValueExpression
(must evaluate to java.lang.Integer )
| Specifies the size of the border around the table. If the value is 0 or absent, no border is rendered |
cellpadding | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Specifies the spacing between data in a table cell and the border of the cell. |
cellspacing | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Specifies the spacing between table cells. |
columnClasses | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| A comma separated list of CSS classes for the table body <td> elements. |
customRowClass | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Binding expression that specifies a custom CSS class name to add to the current row |
dir | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
|
Specifies the directionality of the flow of the content for the current element
Valid values are:
|
filter | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Filter expression |
filterParamName | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Name of request parameter that specifies table's filter expression |
footerClass | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| The CSS class for footer cells |
frame | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
|
Specifies the sides of the outer table border for which to draw borders.
Valid values are:
|
headerClass | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| The CSS class for header cells |
id | false | java.lang.String | Control identifier |
lang | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Specifies the language of the enclosed content |
maxOrdinal | false | javax.el.ValueExpression
(must evaluate to java.lang.Integer )
| Maximum number of sort ordinals allowed (1=primary only, 2=primary and secondary only, etc.) |
onclick | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onclick" event handler |
ondblclick | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "ondblclick" event handler |
onkeydown | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onkeydown" event handler |
onkeypress | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onkeypress" event handler |
onkeyup | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onkeyup" event handler |
onmousedown | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onmousedown" event handler |
onmousemove | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onmousemove" event handler |
onmouseout | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onmouseout" event handler |
onmouseover | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onmouseover" event handler |
onmouseup | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| JavaScript "onmouseup" event handler |
rendered | false | javax.el.ValueExpression
(must evaluate to boolean )
|
True to render control; false to ignore it
If not specified, the default value is "true". |
rowClasses | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| A comma separated list of CSS classes for the table rows. The classes are used for the <tr> elements in the order they are listed, repeating the list over all rows in the table. |
rowHeight | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Row height in pixels (ex '20px') or ems (ex '2em') |
rules | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
|
Specifies the interior dividing line display in a table.
Valid values are:
|
selectedRowClass | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| CSS class name for selected rows |
sortParamName | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Name of request parameter that specifies table's sort info |
style | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| HTML "style" attribute value |
styleClass | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
|
HTML "class" attribute value
Valid values are:
|
summary | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Aids accessibility for non-visual browsers by providing a summary of the table's purpose and structure |
title | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| HTML "title" attribute value (often displayed as a tooltip) |
value | true | java.lang.String | Data model |
var | true | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Name of variable reference to the current row object |
width | false | javax.el.ValueExpression
(must evaluate to java.lang.String )
| Specifies the table width in pixels or a percentage of the available width |
Output generated by Vdldoc View Declaration Language Documentation Generator.