adf tree selection listner not working getting error <oracle.adf.view> <RichRenderer> <decodeUnknownKey> <ATTEMPT_SYNC_UNKNOWN_KEY>

亡梦爱人 提交于 2019-12-25 02:33:19

问题


I have created a tree in adf programtically. It's showing correctly and I am also able to traverse but when I try clicking on any node, my selectionListner() function does not work instead it gives following error on console:

 <oracle.adf.view> <RichRenderer> <decodeUnknownKey>   
<ATTEMPT_SYNC_UNKNOWN_KEY>**

Following is my code 1) I create an Employee class

 package view;
 import java.util.ArrayList;
 import java.util.List;

 public class Employee {
 private String name;
 private String location;
 private List<Employee> directs;

 public Employee(String name, String loc){
    this.name = name;
    this.location = loc;
    directs = new ArrayList<Employee>();
  }

public String getName() {
    return name;
}
  public String getLocation() {
    return location;
  }
  public List<Employee> getDirects() {
    return directs;
  }
  public void addDirect(Employee emp){
    directs.add(emp);
  }}

2) I created a managed bean with a constructor:

List<Employee> allEmployees = new ArrayList<Employee>();
TreeModel employeeTree;

public TestPage_1() {
    super();
    Employee manager1 = new Employee("John","London");
        Employee emp = new Employee("Jack", "London");
        manager1.addDirect(emp);
        emp = new Employee("Ken","New York");
        manager1.addDirect(emp);
        Employee manager2 = new Employee("Ravi","Bangalore");
        emp = new Employee("Ramesh","Bangalore");
        manager2.addDirect(emp);
        Employee manager3 = new Employee("Raju","Pune");
        emp = new Employee("Rakesh","Pune");
        manager3.addDirect(emp);
        manager2.addDirect(manager3);
        emp = new Employee("Jamie","California");

        allEmployees.add(manager1);
        allEmployees.add(manager2);
        allEmployees.add(emp);     

        //Wrapping the list in to a class used by ADF TreeTable.

}

public TreeModel getModel() {
      employeeTree =
          new ChildPropertyTreeModel(allEmployees,"directs");
    return employeeTree;
  }

and a selection Listener:

public void nodeclicked(SelectionEvent selectionEvent) 
    String adfSelectionListener = "#{backingBeanScope.backing_testPage_1.model.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 });

           RichTree tree = (RichTree)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
               System.out.println("View Object name---->" + nodeBinding.getViewObject().getName());

           }
    }

and my tree UI is:

<af:tree id="testPage_tree" var="node" value="#{backingBeanScope.backing_testPage_1.model}"
                         binding="#{backingBeanScope.backing_testPage_1.testPage_tree}"
                         selectionListener="#{backingBeanScope.backing_testPage_1.nodeclicked}">
                    <f:facet name="nodeStamp">
                        <af:outputLabel value="#{node.name}" id="ol1"
                                        binding="#{backingBeanScope.backing_testPage_1.ol1}"/>
                    </f:facet>
                </af:tree>

I am trying to find out which node in tree is selected but my breakpoints do not work in selection listener function.


回答1:


You missed to set rowSelection property of tree component



来源:https://stackoverflow.com/questions/28125809/adf-tree-selection-listner-not-working-getting-error-oracle-adf-view-richrend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!