How to Add Filtering to a Table

10-34 Web User Interface Developers Guide for Oracle Application Development Framework data for each node. Each node is rendered stamped once, repeatedly for all nodes. As each node is stamped, the data for the current node is copied into a property that can be addressed using an EL expression. Specify the name to use for this property using the var property on the tree. Once the tree has completed rendering, this property is removed or reverted back to its previous value. Because of this stamping behavior, only certain types of components are supported as children inside an ADF Faces tree. All components that have no behavior are supported, as are most components that implement the ValueHolder or ActionSource interfaces. In Example 10–11 , the data for each element is referenced using the variable node, which identifies the data to be displayed in the tree. The nodeStamp facet displays the data for each element by getting further properties from the node variable: Example 10–11 Displaying Data in a Tree af:tree var=node f:facet name=nodeStamp af:outputText value={node.firstname} f:facet af:tree Trees also contain a pathStamp facet. This facet determines how the content of the Hierarchical Selector dialog is rendered, just like the nodeStamp facet determines how the content of the tree is rendered. The component inside the pathStamp facet can be a combination of simple outputText, image, and outputFormatted tags and cannot not be any input component that is, any EditableValueHolder component because no user input is allowed in the Hierarchical Selector popup. If this facet is not provided, then the Hierarchical Selector icon is not rendered. For example, including an image and an outputText component in the pathStamp facet causes the tree to render an image and an outputText component for each node level in the Hierarchical Selector dialog. Use the same EL expression to access the value. For example, if you want to show the first name for each node in the path in an outputText component, the EL expression would be af:outputText value={node.firstname}.

10.5.1 How to Display Data in Trees

To create a tree, you add a tree component to your page and configure the display and behavior properties. To add a tree to a page: 1. Create a Java class that extends the org.apache.myfaces.trinidad.model.TreeModel class, as shown in Example 10–10 . Tip: The pathStamp facet is also used to determine how default toolbar buttons provided by the panelCollection component will behave. If you want to use the buttons, add a component bound to a node value. For more information about using the panelCollection component, see Section 10.8, Displaying Table Menus, Toolbars, and Status Bars. Using Tables and Trees 10-35 2. In the Component Palette, from the Common Components panel, drag and drop a Tree to open the Insert Tree dialog. Configure the tree as needed. Click Help or press F1 for help in using the dialog. 3. In the Property Inspector, expand the Data section and set the following attributes: ■ Value : Specify an EL expression for the object to which you want the tree to be bound. This must be an instance of org.apache.myfaces.trinidad.model.TreeModel as created in Step 1. ■ Var : Specify a variable name to represent each node. ■ VarStatus : Optionally enter a variable that can be used to determine the state of the component. During the Render Response phase, the tree iterates over the model rows and renders each node. For any given node, the varStatus attribute provides the following information: – model: A reference to the CollectionModel instance – index: The current row index – rowKey: The unique key for the current node 4. Expand the Appearance section and set the following attributes: ■ DisplayRow : Specify the node to display in the tree during the initial display. The possible values are first to display the first node, last to display the last node, and selected to display the first selected node in the tree. The default is first. ■ DisplayRowKey : Specify the row key to display in the tree during the initial display. This attribute should be set only programatically. Specifying this attribute will override the displayRow attribute. ■ Summary : Optionally enter a summary of the data displayed by the tree. 5. Expand the Behavior section and set the following attributes: ■ InitiallyExpanded : Set to true if you want all nodes expanded when the component first renders. ■ EditingMode : Specify whether for any editable components used to display data in the tree, you want all the nodes to be editable editAll, or you want the user to click a node to make it editable clickToEdit. For more information, see Section 10.1.3, Editing Data in Tables, Trees, and Tree Tables. ■ ContextMenuSelect : Determines whether or not the node is selected when you right-click to open a context menu. When set to true, the node is selected. For more information about context menus, see Chapter 13, Using Popup Dialogs, Menus, and Windows. ■ RowSelection : Set a value to make the nodes selectable. Valid values are: none, single, or multiple. For information about how to then programatically perform some action on the selected nodes, see Section 10.5.5, What You May Need to Know About Programmatically Selecting Nodes. ■ ContentDelivery : Specify when the data should be delivered. When the contentDelivery attribute is set to immediate, data is fetched at the same time the component is rendered. If the contentDelivery attribute is set to lazy, data will be fetched and delivered to the client during a subsequent request. If the attribute is set to whenAvailable the default, the renderer checks if the data is available. If it is, the content is delivered immediately. If it is not, then lazy delivery is used. For more information, see Section 10.1.1, Content Delivery.