Reusable Task Flows

Task Flows are small applications with well-defined business rules. In some cases, a Task Flow may need rules implemented in other Task Flow. Rather than implement this rule in both Task Flows, causing duplication code, we only implement one and insert this inside the other, promoting reuse Task Flows.

In this post we will create an application with two Task Flows, one of them will show the list of employees and the other will show the information about the selected employee.
Download the sample application:

Create a Fusion Web Application (ADF).
When you create an application using the application template provided by JDeveloper, it organizes your workspace into projects, creating and organizing many configuration files needed for the type of application you created. The Fusion Web Application (ADF) template provides a set of project settings needed to create an application that uses ADF Faces for view layer, ADF Page Flow for controller, and ADF Business Components for business layer.

To create Business Components, right-click on Model project, and select New.
Navigate to Business Tier | ADF Business Components | Business Components from Tables, and click on OK.
Select the HR schema connection, and click twice on OK.
On step 1, click on Query to query tables from HR schema.
Select EMPLOYEES, and click on Next.


On step 2, select Employees and click on Next.


On step 3, click on Next.
On step 4, click on Finish.


To create the first Task Flow, right-click on ViewController project, and select New.
Navigate to Web Tier | JSF | ADF Task Flow, and click on OK.
Name it ViewEmployeesTaskFlow, uncheck Create with Page Fragments option, and click on OK.


Create the second Task Flow.
Name it EditEmployeesTaskFlow, uncheck Create with Page Fragments option, and click on OK.


Open the ViewEmployeesTaskFlow.
Drag and drop a view component inside the page, and rename it to ViewEmployees.
Drag and drop the EditEmployeesTaskFlow inside the page.
Drag and drop a Control Flow Case component on ViewEmployees, and than click on EditEmployeesTaskFlow. Change * to goEditEmployeesTaskFlow.


Double-click on ViewEmployees, and click on OK.


Refresh the Data Controls pane, and expand the HrAppModuleDataControl.
Drag and drop EmployeesView1 inside the page, and select Table | ADF Read-only Table.
Check the Single Row option, and click on OK.


Include AFStrecthWidth class to table.


Include two buttons below the table. They must stay within the FORM tag.


Configure the buttons.


For EditEmployeesTaskFlow, change the transaction attribute value to New Transaction always start.


Configure the EditEmployeesTaskFlow.


Select the Router, and configure the navigation rules.


For Commit button, change the End Transaction attribute value to Commit.
For Rollback button, change the End Transaction attribute value to Rollback.


Navigate to Data Controls pane | HrAppModuleDataControl | EmployeesView1 | Operations.
Drag and drop the CreateInsert operation on CreateInsertEmployees.


Double-click on EditEmployees, and click on OK.
Navigate to Data Controls pane, drag and drop EmployeesView1 inside the page, and select Form | ADF Form.
Check Include Submit Button option, and click on OK.


For Submit button, change the Text attribute value to Save and Action attribute value to goCommit.
Include other button, and change the Text attribute value to Cancel, Action attribute value to goRollback and Immediate attribute value to true.


Save everything, and execute the ViewEmployeesTaskFlow.
Select an employee and click on Edit.


Do some changes and click on Save.