Sunday, April 5, 2009

Dumping out pageFlowScope

One of the biggest issues we see with complex applications based on ADF R11 and is the debugging of complex task flows which are nested within regions in pages. Many of these problems resolve down into the task flow simply not having the state that you thought. So you need a simple way to inspect the pageFlowScope variables. Debugging is one option but I also like to have a little interactive output onto the console whilst I’m in the process of running the app. So I put together this simple utility method which I call as the default activity in my bounded task flows:

public String dumpTaskFlowState(){
AdfFacesContext afctx = AdfFacesContext.getCurrentInstance();
Map flowScopeMap = afctx.getPageFlowScope();
String viewPortName =
ControllerState.getInstance().getCurrentViewPort().getClientId(); System.out.println(”—————————————————-”);
System.out.println(”Dumping pageFlowScope Variables for: “);
System.out.println(viewPortName);
Iterator iter = flowScopeMap.entrySet().iterator();
while (iter.hasNext()){
Map.Entry entry = (Map.Entry)iter.next();
String mapKey = entry.getKey().toString();
Object mapValue = entry.getValue();
StringBuilder bldr = new StringBuilder(” “);
bldr.append(mapKey);
bldr.append(”=”);
bldr.append((mapValue==null)?”":mapValue.toString());
System.out.println(bldr.toString());
}
return “continue”;
}

The corresponding method activity that calls this is registered in the task flow xml thus:

#{debugUtil.dumpTaskFlowState}

when the class containing the dump method is defined in the debugUtil managed bean in the same task flow thus:

debugUtil
com.tuhra.ddt.view.util.TaskFlowUtils
request

Finally to wire everything up we set the dumpState method as the default activity and wire up the “continue” outcome to the real start point of the flow.
In time I’ll look at moving this onto a listener rather than having to have it in the flow itself, but it works pretty well as it is.
The output for this thing just appears in the console because I’ve used println() you could use a logger instead. Here’s a sample of the output:

————————————————————
Dumping pageFlowScope Variables for:
data.mainShellPageDef.tabletabflowdefinition1.tableTabContentsPageDef.dynamicQueryRegionflowdefinition1
currentOwner=FOD
currentObject=ADDRESSES
currentType=TABLE
currentSQL=

0 comments: