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: ReusableTaskFlowApp.zip.

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.

reusable-task-flows1

On step 2, select Employees and click on Next.

reusable-task-flows2

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

reusable-task-flows3

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.

reusable-task-flows4

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

reusable-task-flows5

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.

reusable-task-flows6

Double-click on ViewEmployees, and click on OK.

reusable-task-flows7

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.

reusable-task-flows8

Include AFStrecthWidth class to table.

reusable-task-flows9

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

reusable-task-flows10

Configure the buttons.

reusable-task-flows11

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

reusable-task-flows12

Configure the EditEmployeesTaskFlow.

reusable-task-flows13

Select the Router, and configure the navigation rules.

reusable-task-flows14

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

reusable-task-flows15

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

reusable-task-flows16

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.

reusable-task-flows17

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.

reusable-task-flows18

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

reusable-task-flows19

Do some changes and click on Save.

reusable-task-flows20

reusable-task-flows21

Waslley Souza

Author: Waslley Souza

Consultor Oracle com foco em tecnologias Oracle Fusion Middleware e SOA. Certificado Oracle WebCenter Portal, Oracle ADF e Java.

Leave a Reply

Your email address will not be published. Required fields are marked *