Due to jet lag, I have plenty of time to shop around in the candy store that is called ADF 11g. Occasionally, upon close inspection of this or that property inspector, I come across interesting little things that I might as well share with you. Just now I came across the property ‘target data source’ on node rule in the tree data binding editor. It is a nice little fellow: you can specify that upon selection of a node in the iterator based on which you are creating a tree binding node rule, another iterator should be synchronized: the rowkey for the node that is selected is to be used to set the current row for the target iterator.
That means with hardly any effort at all – and completely declaratively – the selection of a node in the tree can lead to synchronization of other parts of the page. I will show you a simple example.
I created a brand new Fusion Web Application in JDeveloper 11g.
I next added an ADF Library that contains the ADF BC definitions for SCOTTs EMP and DEPT. (see for more about creating such a library the article Building a repository of reusable ADF artefacts using ADF Libraries – for example: a reusable Placeholder Data Control ).
Adding the library as an effect on the Data Control palette:
In the ViewController project, I create a new JSF page – called HrmTree.jspx.
I dragged a PanelSplitter to the page – setting its width to 100%. Then I dropped a PanelBox in the first facet of the panel splitter.
Next I drag the DeptView1 collection from the HrmService data control to the page, dropping it as a Tree, in the PanelBox inside the PanelSplitter.
In the Tree Binding editor, I create Tree Level Rules for DeptView1 and EmpView (based on VO Usage EmpInDeptView). I select the attributes to display in the node label. At this point, I will ignore the target data source property.
Next I drag a PanelHeader to the second panelsplitter facet. Then I drop the EmpView1 collection in the PanelHeader as a read only form. It is the intention to have the currently selected Employee node explained in more detail here: this form should be synchronized when a new employee node is selected.
Now we come to the target data source property: we now return to the Tree Binding editor – in the HrmTree page go to the bindings tab. Select the DeptView binding and click on the edit icon.
In the tree binding editor, select the EmpView1 node rule
and set the Target Data Source to refer to the EmpView1Iterator – the iterator that was created when the EmpView1 collection was dropped as a read only form. We want this iterator to be set in accordance with the selected Employee node.
Before we can run the page, we have to do one last thing: at this point, the tree node selection even will lead to synchronization of the target iterator. However, no one will know about it. It is not visible all by itself. So we have to activate PPR: assign a value of hrmtree to the id attribute of the tree component. Add this same value to the partialTrigger attribute on the PanelHeader.
Now run the page.
Whenever an Employee node is selected, the detail form is updated to reflect the properties of the selected Employee.
5 thoughts on “Nice little feature in ADF 11g: 'target data source' attribute on tree binding helps synchronize page with tree node selection”
Could you please explain how do IÂ use the Folder Label FieldÂ in Edit Tree Binding. I would like to display the node label from a database column.
Thank you for the tutorial. It is exactly what I want. But there is something I didn’t understand.
What does thisÂ mean:Â “assign a value of hrmtree to the id attribute of the tree component.”
1. I create a tree, and a detail rad only formÂ on the jspx file
2. I assign the target data source
3. I rename tree (id=maintree) andÂ change event policy of tree component to ppr in pageDef.
4. I set the partitialTrigger of panel header to the tree.
But it is not synchronized. When I click the child row, the form is does not show the selected data.
What may be missing or wrong?
Indeed, Eric’s comment is correct. And for the record – in the other post I try to ban articles on McCain as well.
Edwin, I just read another recent post, where Lucas describes his attempts to get rid of Obama-related info. Nevertheless, the answer to your question is: “Yes We Can!” 😉
Hi Lucas, is this option available for all level in the tree. So you can select a other iterator when you select the deptview
Comments are closed.