Technical Articles relating to Oracle Development Tools and Frameworks

  • ADF
    July 3, 2012

New Sample Demonstrating the Traversing of Tree Bindings

Duncan Mills

A technique that I seem to use a fair amount, particularly
in the construction of dynamic UIs is the use of a ADF Tree Binding to encode a
multi-level master-detail relationship
which is then expressed in the UI in some kind of looping form – usually a
series of nested af:iterators, rather than the conventional tree or treetable.
This technique exploits two features of the treebinding. First the fact that an
treebinding can return both a collectionModel as well as a treeModel, this
collectionModel can be used directly by an iterator. Secondly that the “rows”
returned by the collectionModel themselves contain an attribute called .children.
This attribute in turn gives access to a collection of all the children of that
node which can also be iterated over.

Putting this together you can represent the data encoded
into a tree binding in all sorts of ways.

As an example I’ve put together a very simple sample based
on the HT schema and uploaded it to the ADF Sample project. It produces this

Example output from this technique

The important code is shown here for a Region -> Country -> Location Hierachy:

<af:iterator id="i1" value="#{bindings.AllRegions.collectionModel}" var="rgn">
<af:showDetailHeader text="#{rgn.RegionName}" disclosed="true" id="sdh1">
<af:iterator id="i2" value="#{rgn.children}" var="cnty">
    <af:showDetailHeader text="#{cnty.CountryName}" disclosed="true" id="sdh2">
      <af:iterator id="i3" value="#{cnty.children}" var="loc">
        <af:panelList id="pl1">
        <af:outputText value="#{loc.City}" id="ot3"/>

You can download the entire sample from here:

Join the discussion

Comments ( 5 )
  • Dan Thursday, July 5, 2012

    The link to download the source is broken - it should have "content" in it instead of "conten".

  • Praidp Thursday, July 5, 2012


    your link is not working right now as there is a "t" missing in content folder. My be you could correct it




  • Duncan Friday, July 6, 2012

    Fixed - thanks folks!

  • Dan Friday, July 6, 2012

    How would this work if you have, for example, 2 detail tables for any particular master table, like if region contain both countries and territories? ADF won't know which one to iterate over with rgn.children - in my tests, it just gives you a list of string values of the child view objects, and I can't drill into those to get their attribute values.

  • Duncan Wednesday, July 11, 2012

    You can discriminate at a particular level in the tree using node definition which can be accessed thus: #{childIterator.hierTypeBinding.viewDefName} where childIterator is the var you've used in the parent iterator.

    This expression will return the DefName ID that you see associated with the node in the TreeBinding (<nodeDefinition DefName="oracle.demo.model.queries.queries.CountriesView" ...>)

    So you can use a switcher or the rendered attribute based on this expression.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.