Selecting a node on an ADF Tree control sets the current record in a different data source

While doing some redevelopment of a Forms application in ADF the following use case came up.  The user is able to view a tree which shows either SalesReps and their customers, or, Countries and their Customers.  So, how could I implement this in ADF?


The key was that, in my mind, the data model was something like this:

Countries or SalesReps

---Customers

-------Orders

----------OrderItems

At first I thought that in the application module I might have two hierarchies.  One with Countries as the top node, and another with SalesReps as the top node.  However, there was a different way:

I created the data model to look like this:

datamodel.png

Here you can see that Countries and Emps (SalesReps) are at the top level but so is Customers.

I then created my page to look something like this:

page.png

The key point was that the tree control didn't need the data model to physically be Countries (or SalesReps) and then Customers as a detail of that.  So long as there was a view link accessor from Countries to Customers (and the same for SalesReps to Customers) then the tree control could make use of that.

So the next step, on selecting a node in the tree, how could I synch that to the form on the right of the page which was bound to the Customers data control?  Well it turns out ADF makes this easy.  If you go to the binding for the tree control you will see the following:

tree.png

The point to note is Target Data Source which points to the Customers iterator.  This means that on selecting the tree node, the tree will force an update of the Customers iterator.  The only other thing you need to do is set PPR so the page updates correctly.

 

So you get:

 

result.png

The only additional piece of work was that on the AM instance for Customers, select the Edit button and set Tuning to No Rows.  This will prevent Customers from being queried before clicking on a tree node. 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Tips, Tricks, Events and Information around Oracle JDeveloper, ADF, and Oracle Forms

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today