How to display the path of selected node of a tree table.

Hi,
I have one use case where I have to display the path of node of tree table which is selected one.
e.g.
Suppose the tree table is like this.
Folder1(root)
          ->folder2
          ->folder3
                    ->folder4
Now when I select this folder1 then path display should be "/folder1(root)"
when i select the folder4 then path should be "/folder1(root)/folder3/folder4"
Hope this one will help to understand my use case..
Thanks
Advertisement
Reply

Hello,
try this:
jsp page:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:messages id="m1"/>
      <af:form id="f1">
        <af:tree value="#{bindings.RootNodes.treeModel}" var="node"
                 rowSelection="single" id="t1" expandAllEnabled="true"
                 rowDisclosureListener="#{Test.testDisclosureListener}"
                 selectionListener="#{Test.SelectionListener}">
          <f:facet name="nodeStamp">
            <af:panelGroupLayout id="pgl0">
              <af:outputText rendered="#{empty node.Link}" value="#{node.Edesc}"
                             id="ot1"/>
              <af:goLink rendered="#{!empty node.Link}" targetFrame="_blank" text="#{node.Edesc}" destination="#{node.Link}"  id="gl1"/>
            </af:panelGroupLayout>
          </f:facet>
        </af:tree>
        <af:outputText value="#{bindings.Id.inputValue}" id="ot2"
                       partialTriggers="t1">
          <af:convertNumber groupingUsed="false"
                            pattern="#{bindings.Id.format}"/>
        </af:outputText>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>
code:
package testing;
import java.util.Iterator;
import java.util.List;
import model.businessObjects.view.ZamerTreeMenuViewRowImpl;
import oracle.adf.view.rich.component.rich.data.RichTree;
import oracle.jbo.Row;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;
import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;
import org.apache.myfaces.trinidad.event.RowDisclosureEvent;
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.CollectionModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
public class Test{
    public Test(){
    public void testDisclosureListener(RowDisclosureEvent rowDisclosureEvent){
        RichTree tree1=(RichTree)rowDisclosureEvent.getSource();
        CollectionModel model = (CollectionModel)tree1.getValue();
        JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
        JUCtrlHierNodeBinding start = null;
        List focus = (List)tree1.getFocusRowKey();
        tree1.setRowKey(rowDisclosureEvent.getAddedSet().iterator().next());
        System.out.println("testing.Test.testDisclosureListener>>"+treeBinding.getPath());
        start = (JUCtrlHierNodeBinding)tree1.getRowData();
//        ZamerTreeMenuViewRowImpl temp = (ZamerTreeMenuViewRowImpl)start.getRow();
        JUCtrlHierNodeBinding parent=start.getParent();
        String path="";
        ZamerTreeMenuViewRowImpl  r = (ZamerTreeMenuViewRowImpl)start.getRow();
        path+="/"+r.getAdesc();
        while(parent!=null){
            r = (ZamerTreeMenuViewRowImpl)parent.getRow();
            if(r==null){
                break;
        System.out.println("testing.Test.testDisclosureListener>>"+path);