X

Shay Shmeltzer's Oracle Development Tools Tips

  • December 17, 2009

Displaying Hierarchical Data from a Web Service in JSF with ADF

Shay Shmeltzer
Director of Product Management - Oracle

Someone asked on OTN if we can use data coming from a Web service to populate a hierarchical tree in a JSF page.

The answer is yes - and with the Web service data control this is actually very simple in JDeveloper 11g.

Here is a quick demo:

Join the discussion

Comments ( 11 )
  • Sachin Gupta Tuesday, November 29, 2011

    Hi Shay,

    Is there a way by which I can display a check box in front of every node in af:tree. And whenever I select a node, all the children should be selected.

    If yes, how to do it, and how to read the selected values?

    Thanks in advance.


  • Shay Tuesday, November 29, 2011

    Sachin, you should be able to add a checkbox in the tree node - but you'll need to programatically code the selection of the node and all the children in that checkbox's listener.


  • guest Sunday, January 22, 2012

    Hey Shay, The video is not available. Can u upload it again.Thanks, Ravi.


  • Shay Monday, January 23, 2012

    guest - the video works fine for me - make sure you can watch youtube videos on your machine - also available from my youtube channel at:

    http://www.youtube.com/watch?v=ImDwxof7_xY


  • Sumit Dey Monday, May 21, 2012

    Please let me know where do I get the source code(Web services code)of this video.


  • Shay Monday, May 21, 2012

    Sumit, the basic workspace I use for the Webservice is here:

    https://blogs.oracle.com/shay/resource/pojo.zip


  • Sumit Dey Wednesday, May 23, 2012

    Is it possible to reverse the tree hierarchy (Last node becomes the first node), if possible how we can implement that.


  • Shay Wednesday, May 23, 2012

    Sumit - it all depends on the model that populate the tree - so if your model is reversed the tree would show it accordingly. There is no built in function to do this automatically.


  • Sumit Dey Thursday, May 24, 2012

    I want to show details of tree control data dynamically, suppose I have created a tree with 5 levels, First use a panelSpliter for the application. Left hand side I have added a tree control other side of spliter would be show details form, now I able able to show details on 2nd part of panelSpliter, but I want to show details in different hierarchy level in same area, now I can able to show the details to the different tab, but now I want to show that when I click on a node, it should show in same place (don't want to show in different tabs or different place).[every level have their own view (Data Control)]

    Thanks in advance.


  • Shay Thursday, May 24, 2012

    Sumit - so your question is can I show different things on one side of the page based on what was clicked in a tree?

    The answer is yes - you can use dynamic regions to get this.

    For example:

    http://biemond.blogspot.com/2008/10/dynamic-regions-with-task-flow-in.html


  • Abhijit Saturday, July 20, 2013

    Hi Shay,

    I am trying to get selected values of a tree, but at a time I am getting only single selection. Can u suggest what changes I need to make below inorder to get selected values.

    public void treeTableSelectionListener(SelectionEvent selectionEvent) {

    String adfSelectionListener = "#{bindings.Return.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)rksIterator.next();

    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

    actualList = new ArrayList<SelectItem>();

    actualList.add(new SelectItem(rw.getAttribute(0)));

    System.out.println("View Object name---->" + nodeBinding.getViewObject().getName());

    setActualList(actualList);

    }

    // AdfFacesContext.getCurrentInstance().addPartialTarget(rwe);

    }


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