Tree Table Component in Oracle ADF(Hierarchical Representation)

Sharing is Caring

Hello All
This post is about ADF Faces Tree Table component (about designing component and get selected value from tree table). We have a simple sample application that shows how can we use tree table component in Oracle ADF.
Tree Table component represents the Hierarchical view of Master-Detail form of data

Here we take an example from HR schema using Employees and Department table
Follow these steps –

  • Create EOs, VOs of Employees and Department table in HR Schema and create an association and view link between Department To Employees considering Department Id
  • Now go to data control and select Department table and drop it on the page as a Tree table 
Tree Table Component in Oracle ADF
  • Now we have to edit its bindings, it means you have to select attributes that you want to display in the page, and below Department table, you should add Employees table using “add” button on top, and select appropriate Iterator in EL picker
Edit tree binding in pageDef
  • Now go to the page and select treetable in Structure window of JDeveloper and Go to its selection listener and copy default value
Override default selection listener
  • And change selection listener set it to the bean, click on edit and create new selection listener in Bean

Create custom selection listener in managed bean for af:treeTable
  •  Now go to Selection Listener and Use this code to get Value of selected node in treetable, if you will get the value of node you can perform any operation on Tree Table

public void treeTableSelectionListener(SelectionEvent selectionEvent) {
String adfSelectionListener = “#{bindings.Department1.treeModel.makeCurrent}”;

FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
ELContext elCtx = fctx.getELContext();
ExpressionFactory exprFactory = application.getExpressionFactory();
MethodExpression me = null;
me =
exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class, new Class[] { SelectionEvent.class });
me.invoke(elCtx, new Object[] { selectionEvent });

RichTreeTable tree = (RichTreeTable)selectionEvent.getSource();
TreeModel model = (TreeModel)tree.getValue();
//get selected nodes
RowKeySet rowKeySet = selectionEvent.getAddedSet();
Iterator rksIterator = rowKeySet.iterator();
while (rksIterator.hasNext()) {
List key = (List);
JUCtrlHierBinding treeBinding = null;
treeBinding = (JUCtrlHierBinding)((CollectionModel)tree.getValue()).getWrappedData();
JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
Row rw = nodeBinding.getRow();
System.out.println(“row: “ + rw.getAttribute(0)); // You can get any attribute
System.out.println(“View Object name—->” + nodeBinding.getViewObject().getName());



  •  Now run your page and when you will click on any node you will find its value on Console

Sample ADF Application 

Cheers 🙂 Happy Learning

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *