5-12 Java EE Developers Guide for Oracle Application Development Framework
tree IterBinding=orderItemFindAllIterator id=orderItemFindAll nodeDefinition DefName=oracle.fodemo.supplier.model.OrderItem
Name=orderItemFindAll0 AttrNames
Item Value=orderId AttrNames
Accessors Item Value=product
Accessors nodeDefinition
nodeDefinition DefName=oracle.fodemo.supplier.model.Product Name=orderItemFindAll1
AttrNames Item Value=productName
AttrNames nodeDefinition
tree bindings
The tree element is the value binding for all the attributes displayed in the tree. The iterBinding
attribute of the tree element references the iterator binding that populates the data in the tree. The AttrNames element within the tree element
defines binding objects for all the attributes in the master collection. However, the attributes that you select to appear in the tree are defined in the AttrNames elements
within the nodeDefinition elements.
The nodeDefinition elements define the rules for populating the nodes of the tree. There is one nodeDefinition element for each node, and each one contains the
following attributes and subelements:
■
DefName : An attribute that contains the fully qualified name of the data collection
that will be used to populate the node
■
id : An attribute that defines the name of the node
■
AttrNames : A subelement that defines the attributes that will be displayed in the
node at runtime
■
Accessors : A subelement that defines the accessor attribute that returns the next
branch of the tree The order of the nodeDefintion elements within the page definition file defines the
order or level of the nodes in the tree, where the first nodeDefinition element defines the root node. Each subsequent nodeDefinition element defines a subnode
of the one before it.
5.4.3 What Happens at Runtime: Displaying an ADF Databound Tree
Tree components use org.apache.myfaces.trinidad.model.TreeModel to
access data. This class extends CollectionModel, which is used by the ADF Faces table
component to access data. For more information about the TreeModel class, refer to the ADF Faces Javadoc.
When a page with a tree is displayed, the iterator binding on the tree populates the root nodes. When a user expands or collapses a node to display or hide its branches, a
DisclosureEvent event is sent. The isExpanded method on this event determines
whether the user is expanding or collapsing the node. The DisclosureEvent event has an associated listener.
Displaying Master-Detail Data 5-13
The DisclosureListener attribute on the tree is bound to the accessor attribute specified in the node rule defined in the page definition file. This accessor attribute is
invoked in response to the DisclosureEvent event; in other words, whenever a user expands the node the accessor attribute populates the branch nodes.
5.5 Using Tree Tables to Display Master-Detail Objects
Use the ADF Faces treeTable component to display a hierarchy of master-detail collections in a table. The advantage of using a treeTable component rather than a
tree component is that the treeTable component provides a mechanism that
enables users to focus the view on a particular node in the tree. For example, you can create a tree table that displays three levels of nodes: countries,
states or provinces, and cities. Each root node represents an individual country. The branches off the root nodes display the state or provinces in the country. Each state or
province node branches to display the cities contained in it.
As with trees, to create a tree table with multiple nodes, it is necessary to have master-detail relationships between the collections. For example, to create a tree table
with three levels of country, state, and city, it was necessary to have a master-detail relationship from the CountryCodes collection to the StatesandProvinces
collection, and a master-detail relationship from the StatesandProvinces collection to the Cities collection.
A databound ADF Faces treeTable displays one root node at a time, but provides navigation for scrolling through the different root nodes. Each root node can display
any number of branch nodes. Every node is displayed in a separate row of the table, and each row provides a focusing mechanism in the leftmost column.
You can edit the following treeTable component properties in the Property Inspector:
■
Range navigation: The user can click the Previous and Next navigation buttons to scroll through the root nodes.
■
List navigation: The list navigation, which is located between the Previous and Next
buttons, enables the user to navigate to a specific root node in the data collection using a selection list.
■
Node expanding and collapsing mechanism: The user can open or close each node individually or use the Expand All or Collapse All command links. By default,
the icon for opening and closing the individual nodes is an arrowhead with a plus or minus sign. You can also use a custom icon of your choosing.
■
Focusing mechanism: When the user clicks on the focusing icon which is displayed in the leftmost column next to a node, the page is redisplayed showing
only that node and its branches. A navigation link is provided to enable the user to return to the parent node.
5.5.1 How to Display Master-Detail Objects in Tree Tables
The steps for creating an ADF Faces databound tree table are exactly the same as those for creating an ADF Faces databound tree, except that you drop the accessor returned
collection as an ADF Tree Table instead of an ADF Tree.
5.5.2 What Happens When You Create a Databound Tree Table
When you drag and drop from the Data Controls panel, JDeveloper does many things for you.