Freitag, September 10, 2004

 

Fetch children from any service method in ADF-Treebinding

With ADF-TreeBinding you have the only possibility to get the children nodes from the same BeanClass used to render the current node self. Therefor you must add a getter method that return a collection of childrens in the node bean. There is no possibility to delegate the call to an other service routine e.g. to a delegate class. With the proxy pattern you can solve this problem easily. You must wrap the node bean in a proxy class and delegate each call to wrapped node expect your getChildren() method. This method can use any service class to retrieve the children nodes and store the returned children's as proxies in the instance. Additional you must bind the proxy to the tree and not the node bean. This little trick make it ease to avoid the ADF-Binding restrictions.

Example code:

class MyNode implements Node {
...
int getId() {...}
String getName() {...}
List getChildren(){...}
...
}

class ProxyNode implements Node {
Node node = null;
Service service = null;
ProxyNode(Service service, Node node) {
this.node = node;
this.service = service;
}

String getName(){
// delegate to org node
return node.getName();
}

List getChildren(){
if(node.getChildren() == null){
return service.getChildrenNodes(node.getId());
}
return node.getChildren();
}
...
}


Attention, the tree binding fetch alway the actual selected node and all nodes of his children nodes to know which rendering mode to use (icon, link ...)






<< Home

This page is powered by Blogger. Isn't yours?