Hello All
We all use bounded task flows in ADF application development and to switch between multiple task flows we use concept of dynamic region
Recently I came across a problem about dynamic region and bounded task flows, Scenario is like this
I have dropped a BTF in dynamic region and there is a link on page to open that task flow and those who have used dynamic region would be familiar with this piece of code
private String taskFlowId = "/WEB-INF/task-flow-definition.xml#task-flow-definition"; public TaskFlowId getDynamicTaskFlowId() { return TaskFlowId.parse(taskFlowId); } public void setDynamicTaskFlowId(String taskFlowId) { this.taskFlowId = taskFlowId; } //Method to open BTF public String testDocTF() { setDynamicTaskFlowId("/WEB-INF/TestDocTF.xml#TestDocTF"); return null; }
and important thing is that this BTF has two view activities (view1 and view2), view1 is default activity.
When user clicks on link it opens default activity in dynamic region and then user navigate to second activity by clicking a button on default activity
Now user clicks the link again but this time page refreshed but default activity is not loaded, dynamic region shows second activity (It is not expected as requirement is to re-initialise task flow and load default activity again)
So to do that we need to refresh task flow and for that just add one more line in code, Bind region to bean and refresh it
private RichRegion regionBind; public void setRegionBind(RichRegion regionBind) { this.regionBind = regionBind; } public RichRegion getRegionBind() { return regionBind; } //Method to open BTF public String testDocTF() { //Refresh region and re-initialise taskFlow regionBind.refresh(FacesContext.getCurrentInstance()); setDynamicTaskFlowId("/WEB-INF/TestDocTF.xml#TestDocTF"); return null; }
Cheers :) Happy Learning
No comments :
Post a Comment