Sample UseCase:
For example if a Jsf Page contains departments table and on selecting a department from the table and click on button 'Show Employees', it should display the employees in the selected department. But suppose the employee details should come from a different task flow. We need to establish the communication between the parent jsf page and the task flow region in it. Sample application for this example can be downloaded from here.
Implementation Steps:
Task flow refresh Principle:
If you drop a task flow that takes some parameters as a region in a jsff page, the task flow binding will be added in the pagedef file. If you set refresh='ifNeeded' for the task flow binding, the task flow will be re-executed each time when the value for one of the passed parameters got changed. To be clear, here re-execution means the task-flow will re-execute from it's default activity in the task flow diagram.
This example depends on the above principle.
1. Create a jsff page and include departments table and add a button 'Show Employees'.
2. Create a task flow that takes deptId as parameter and fetches the employees present the given department and shows them in a table.
Task flow diagram with input parameter deptId:
3. Specify actionListener for the 'Show Employees' button and in the actionListener method, get the deptId selected in departments table and set to to a pageFlowScope variable.
Java bean containing the actionListener method for 'Show Employees' button:
public class ExampleBean { private Integer deptId; public void buttonClicked(ActionEvent ae){ Row currentDeptRow=(Row)ADFUtil.evaluateEL("#{bindings.DeptVO.currentRow}"); ADFUtil.setEL("#{pageFlowScope.deptId}",currentDeptRow.getAttribute("Deptno")); } public void setDeptId(Integer deptId) { this.deptId = deptId; } public Integer getDeptId() { return deptId; } }
4. Drop the employee details task flow as a region in the jsf page. Pass the same above pageFlowScope variable as a parameter to the dropped taskflow. Specify refresh="ifNeeded" for the task flow binding in pagedef.
Task flow binding in the pagedef:
<taskFlow id="TaskFlow21" taskFlowId="/com/demo/taskflows/TaskFlow2.xml#TaskFlow2" xmlns="http://xmlns.oracle.com/adf/controller/binding" Refresh="ifNeeded" activation="deferred"> <parameters> <parameter id="deptId" value="#{pageFlowScope.deptId}"/> </parameters> </taskFlow>
That's it. This is how it works: When the user selects department in jsff and clicks on 'Show Employees' button, the actionListener method sets the pageFlowScope variable with the deptId selected and the same will be passed to the dropped task flow. As the task flow re-executes if any of it's input parameter changes, the employees will be queried based on passed deptId and the task flow will refreshed with the corresponding employee details. No 'partialTriggers' is required in this case. Refresh of task flow will be triggered automatically when the input parameter value is changed.
Sample screen shots:

