Let’s observe the task flow’s input parameters. In the Structure window, expand
the ADF Task Flow node, right-click
the task-flow-definition node beneath
it, and select Go to Properties. In the
Property Inspector, select the Parameters
section to see that two input parameters
named mode and rowKeyStr ToEdit are
defined. When this modify-department
task flow is invoked, the caller passes
values for these parameters. You can see
that the mode parameter is required,
whereas the rowKeyStr ToEdit parameter
is optional. The expression language (EL)
expression #{ pageFlowScope.mode} in the
Value column of the Input Parameter
Definitions table indicates where the
Oracle ADF runtime will save the mode
input parameter value for reference by
the activities and pages in the task flow.
The convenient pageFlowScope is a map
of name/value pairs where task flow
input parameter values can be saved for
the duration of the task flow.
Select the RouteByMode activity
in the modify-department task flow
diagram, and in the Common section
of the Property Inspector, note how EL
expressions are configured to conditionally choose the navigation outcome.
If the pageFlowScope.mode attribute
equals Add, then the RouteByMode
activity uses the Create control flow to
route control to the CreateDepartment
method call activity to create a new
department. If this pageFlowScope.mode
attribute equals Edit, the RouteByMode
activity uses the Find control flow and
invokes the FindDepartment activity instead. Both of these method
call activities forward control to the
EditDepartment view activity.
Double-click the EditDepartment
view activity in the modify-department
task flow to open the corresponding
EditDepartment.jspx page in the visual
editor. Select the Output Text component in the panel box at the top of the
page; in the Property Inspector, the EL
expression, in its Value property, uses
conditional expressions involving the
mode attribute to output an appropriate message. Click Save in the visual
editor to observe that its Action property
is set to the Save outcome, which will
forward control to the SaveChanges task
flow return activity when that button
is clicked. Similarly, the Cancel button’s Action property is set to the Cancel
outcome, which will navigate to the
CancelChanges return activity.
Another key feature of a bounded task
flow is its optional declarative transaction handling. Let’s see how the
modify-department task flow leverages this
capability. Click the modify-department
task flow editor’s tab to bring it to the
front. Select the task-flow-definition
node in the Structure window, and select
the Behavior section in the Property
Inspector. Note that under the Transaction
heading, the transaction property is set
to requires-transaction, which tells the
Oracle ADF runtime that the task flow is
transaction-aware. The data-control-scope
setting shared indicates that when this
task flow is called, any data controls it
uses will be included in the same transaction as the calling page flow. Select the
SaveChanges task flow return activity in
the diagram, and note in the Behavior
section of the Property Inspector that
its End Transaction property is set to
commit. This indicates that when this
return activity is executed, Oracle ADF
should automatically commit the transaction. In contrast, for the CancelChanges
return activity, the End Transaction property is configured to perform a rollback.
CONFIGURING THE METHOD ACTIVITIES
In the modify-department task
flow, make note of the warning
symbols on the FindDepartment and
CreateDepartment method call activities. This indicates that these activities
are not fully configured yet. To remedy
the situation, expand the Data Controls
section of the Application Navigator
and expand HRModuleDataControl,
the Departments data collection, and
the Operations folder it contains.
Drag the Create operation node that
appears there, and drop it onto the
CreateDepartment method call activity.
Select the CreateDepartment activity in
the diagram, and in the Common section
of the Property Inspector, select Edit
from the fixed-outcome property list.
Repeat these steps to drag the
setCurrentRow WithKey operation for
the Departments data collection from
the Data Controls palette and drop it
onto the FindDepartment method call
activity. As before, set the fixed-outcome
property to Edit.
Next, configure the parameter for the
setCurrentRow WithKey action binding
related to this method call. Right-click
the FindDepartment activity and
choose Edit Binding. In the Parameters
section, enter the EL expression
#{ pageFlowScope.rowKeyStr ToEdit} in the
Value column for the rowKey parameter
of the action binding and then click
OK. Finally, ensure that validation is
disabled on the page definitions related
to the two action bindings. To do
this, right-click the FindDepartment
activity and choose Go to Page
Definition. In the Structure window,
select the top-level node and ensure
that the SkipValidation property is set
to true. Repeat the same steps for the
CreateDepartment activity.
CALLING A TASK FLOW
As a last step before running the application, we’ll finish configuring an
unbounded task flow that invokes the
bounded modify-department task flow
above. Double-click the adfc-config
XML file under the Page Flows folder
in the Application Navigator to open it
in the editor. This task flow contains the
BrowseDepartments view activity that
forwards to a modify-department task
flow call activity that I created by simply
dropping the modify-department task
flow from the Application Navigator onto
the diagram. The modify-department
task flow call activity appears with a
red X icon, because the required mode
parameter that the modify-department
bounded task flow expects has not yet
been configured.
Open the BrowseDepartments.jspx
page in the visual editor, and select the
Add button. In the Property Inspector,
you can see that its Action property
triggers the AddOrEdit control flow
rule. Selecting the af:setActionListener
component (nested inside this
af:commandButton component in the