Communication between Task Flows using Task Flow Parameters

In order to create an enterprise application, usually are required many task flows. These task flows will perform different functions, but they may have to communicate each other. To enable this communication, you can use Task Flow Parameters, Contextual Events or Sharing Data Control Instances.

Ps.: Register parameters within the session scope with a task flow and use them in another task flow is not a good practice, do not use!

In this article, I will describe the Task Flow Parameters, creating a navigation between two pages. The first Task Flow will display the list of employees, and the second Task Flow, will display the information of selected employee.

For this, we will need only the JDeveloper 12c (12.1.3.0.0) and the HR schema. Download the sample application: ADFTaskFlowParamApp.zip.

Create an ADF Fusion Web Application, and call it as TaskFlowParamApp.

communication-task-flows-using-task-flow-parameters1

Create the Business Components, using the Employees table.

communication-task-flows-using-task-flow-parameters2

First of all, let’s create the Task Flow that contains the information of selected employee. Select the ViewController project, create an ADF Task Flow and call it as EditEmployeeTaskFlow.
Uncheck the “Create with Page Fragments” option, so the views are created as full pages instead of fragments. This configuration is necessary because the fragments of pages only run when they are inserted into complete pages.

communication-task-flows-using-task-flow-parameters3

Drag into the EditEmployeeTaskFlow, the Method Call, View and Task Flow Return components, located in the Components panel. Connect them using the Control Flow Case component.
Name the components: Method Call as setEmployeeId, as EditEmployee View, Task Flow Return as TaskFlowReturn, and Control Flow Case as goEditEmployee and goTaskFlowReturn.
The Default Activity is the entry point of the Task Flow, and is signaled by the green circle. In EditEmployeeTaskFlow, the default activity is setEmployeeId. If not, select the setEmployeeId and click the green circle icon.

communication-task-flows-using-task-flow-parameters4

In the Data Controls panel, navigate to AppModuleDataControl > EmployeesView1 > Operations. Drag the setCurrentRowWithKey opertaion and drop in setEmployeeId component.
In the Edit Action Binding window, configure RowKey parameter with #{pageFlowScope.employeeSelected} value, and click OK. The setCurrentRowWithKey operation takes the input parameter (employee ID), and sets the iterator of EmployeesView1.

communication-task-flows-using-task-flow-parameters5

Navigate to Overview > Parameters and add the input parameter of Task Flow. The name should be employeeSelected, the class=java.lang.String, the value=#{pageFlowScope.employeeSelected} and required=false.

communication-task-flows-using-task-flow-parameters6

Double-click the EditEmployee and click OK to create the EditEmployee.jsf page.

communication-task-flows-using-task-flow-parameters7

To create the form that will display the information of selected employee, navigate to Data Controls panel, expand the AppModuleDataControl, select the EmployeesView1, drag it into the ViewEmployees.jsf page, and select ADF Form option.

communication-task-flows-using-task-flow-parameters8

Check the Submit option, and click OK to create the form.

communication-task-flows-using-task-flow-parameters9

In the form, select the Submit button in the Properties panel and change the Text property to Action and Back property to goTaskFlowReturn.
With this configuration, when we click the Back button, the flow goTaskFlowReturn will run, and the TaskFlowReturn component will return the navigation to the Task Flow which started the execution of the EditEmployeeTaskFlow.

communication-task-flows-using-task-flow-parameters10

Now let’s create a page that contains a list of employees. Navigate to the ViewController project > Web Content > Page Flows and open the adfc-config.xml file. This file is the default Unbounded Task Flow.
The Bounded Task Flow is a specialized form of Task Flow, with only one entry point and zero or more exit points. But the Unbounded Task Flow can have a collection of activities and control flow rules, with multiple entry points and multiple exit points. A typical application is the combination of an Unbounded Bounded and one or more Flows Task.

communication-task-flows-using-task-flow-parameters11

Drag a View component and the EditEmployeeTaskFlow.xml file inside the adfc-config.xml. Connect them using the Control Flow component.
Rename them: View as ViewEmployees and Control Flow Case as goEditEmployeeTaskFlow.

communication-task-flows-using-task-flow-parameters12

Double-click the ViewEmployees component and click OK to create the ViewEmployees.jsf page.

communication-task-flows-using-task-flow-parameters13

To create the list of employees, navigate to Data Controls panel and expand the AppModuleDataControl. Select the EmployeesView1, drag inside the ViewEmployees.jsf page and choose Table/List View > ADF Table.

communication-task-flows-using-task-flow-parameters14

Check the Single Row and Read-Only Table options, and click OK to create the table.

communication-task-flows-using-task-flow-parameters15

We will use the Panel Collection component to add many features to table. Navigate to Structure panel, right-click the af:table -t1 node and choose Surround With.

communication-task-flows-using-task-flow-parameters16

Select the Panel Collection component and click OK.

communication-task-flows-using-task-flow-parameters17

Add a button to navigate to view that will display the information of selected employee. In the Panel Collection, right-click the toolbar and choose Insert Inside Facet toolbar > Toolbar.

communication-task-flows-using-task-flow-parameters18

In the Panel Collection, right-click the toolbar and choose Insert Inside Toolbar > Button.

communication-task-flows-using-task-flow-parameters19

Select the button, and in the Properties panel set the properties: Text to Edit and Action to goEditEmployeeTaskFlow.
Using this configuration, when we click the Edit button, the goEditEmployeeTaskFlow flow will run, initializing the EditEmployeeTaskFlow with the selected employee.

communication-task-flows-using-task-flow-parameters20

Configure the Edit button to send the ID of employee to EditEmployeeTaskFlow. Right-click the Edit button and select Insert Inside Button > Browse. In the Insert window, choose the Set Action Listener component and click OK.

communication-task-flows-using-task-flow-parameters21

In the Insert Set Action Listener window, set From as #{bindings.EmployeesView1Iterator.currentRowKeyString} and To as #{pageFlowScope.employeeSelected}, and click OK.

communication-task-flows-using-task-flow-parameters22

Done!
Navigate to ViewController project, right-click the adfc-config.xml file and choose Run.

communication-task-flows-using-task-flow-parameters23

In the Set Run Configuration window, select the ViewEmployees option and click OK.

communication-task-flows-using-task-flow-parameters24

The application will run automatically in your web browser.
Select an employee and click the Edit button to go to next page.

communication-task-flows-using-task-flow-parameters25

The information of selected employee will appear on the form.

communication-task-flows-using-task-flow-parameters26

Click the Back button to go back to list of employees.

communication-task-flows-using-task-flow-parameters27

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 *