Skip Headers
Oracle® Application Development Framework Developer's Guide
10g (10.1.3.1.0)

Part Number B28967-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

13.8 Adding ADF Bindings to Trees and Tree Tables

You can add ADF bindings to ADF Faces tree and tree table components. The ADF Faces tree component displays a hierarchy of master-detail related data collections in a tree format. A databound ADF Faces tree displays multiple root nodes that are populated by a binding on a master data collection. Each node in the tree may have any number of branches, which are populated by bindings on detail data collections. Each node in the tree is indented to show its level in the hierarchy. The ADF tree component includes mechanisms for expanding and collapsing the tree. By default, the icon for each node in the tree is a folder; however, you can use your own icons for each level of nodes in the hierarchy. The ADF Faces tree table components display a hierarchy of master-detail collections in a table. For more information about master-detail relationships and trees, see Chapter 8, "Displaying Master-Detail Data".

13.8.1 How to Add ADF Bindings to Trees and Tree Tables

To add ADF bindings to a tree or tree table, you drag a master data collection from the Data Control Palette and drop it on the tree tag displayed in the Structure window. For general tips about dropping items from the Data Control Palette onto the Structure window, see Section 13.3.1, "How to Add ADF Bindings Using the Data Control Palette".

To add ADF bindings to a tree component:

  1. With the page displayed in the Design page of the visual editor, open the Structure window.

  2. In the Design page of the visual editor, select the tree tag.

    JDeveloper simultaneously selects the corresponding tag in the Structure window. If the incorrect tag is selected, make the adjustment in the Structure window.

  3. From the Data Control Palette, drag a data collection to the Structure window and drop it on the selected tree tag. The data collection you select should be the master collection, which will populate the root node of the tree.

  4. On the Data Control Palette context menu, choose Bind Existing Tree.

  5. Use the Tree Binding Editor to define the root and branch nodes of the tree. For information, see Section 8.4, "Using Trees to Display Master-Detail Objects".

13.8.2 What Happens When You Add ADF Bindings to a Tree or Tree Table

Example 13-9 displays a tree before the ADF bindings are added. Notice that the value attribute specifies the root node as users, and the var attribute specifies the first branch as service requests.

Example 13-9 ADF Faces Tree Before ADF Bindings

<af:tree value="users" var="service requests">
   <f:facet name="nodeStamp">
      <h:outputText/>
   </f:facet>
</af:tree>

Example 13-10 displays the same tree after the User data collection from the SRDemo data control was dropped on it. The User collection is returned by the findAllStaff method. The User data collection will populate the root node, and the serviceRequests collection was defined as a branch off the root nodes. The binding replaced the value attribute with a binding on the findAllStaff1 binding object. The var attribute now contains a value of node, which provides access to the current node. The nodes themselves are defined in the page definition file.

Example 13-10 ADF Faces Tree After ADF Bindings Are Added

<af:tree value="#{bindings.findAllStaff1.treeModel}" var="node">
   <f:facet name="nodeStamp">
      <af:outputText value="#{node}"/>
   </f:facet>
</af:tree>

In addition to adding the bindings to the tree, JDeveloper automatically adds several binding objects for the tree to the page definition file. The executables element defines the iterator binding for the collection that populates the root node.

The bindings element contains a methodAction binding object, which encapsulates the information needed to invoke the method that populates the root node. In the value bindings, the tree is bound to the findAllStaffIter iterator. Each attribute returned by the iterator is listed in the AttrNames element, but only the attributes in the nodeDefinition element are displayed in the tree. The Accesssors element defines the accessor methods that will be used to retrieve the data that will populate the branches in the node. In the example, the User node, which is the root node, defines serviceRequestCollectionAssignedTo as the accessor method. This method returns the service requests for each user node.

For more information about trees and tree tables, see Chapter 8, "Displaying Master-Detail Data".