ADF Task Flows is a new feature that will ship with ADF 11g. In simple terms, it is a tool to encapsulate page flow/navigation. It is much more than that in reality. A set of screens grouped into a Task Flow can be reused from wherever the application requires the same business function. A task flow can be a completely independent component with interaction through input and return parameters. A cool feature is when a task flow is generated as using page fragments (Note: a task flow can have either JSF Pages or JSF Fragments; not both). Such a task flow can be embedded into an existing screen as a region, so you have a main frame that stays static while a sub region contains an entire flow. Cool, isn’t that? The main component is the task flow definition file. This is an xml file on the lines of the faces-config.xml and adfc-config.xml. The various pages in a flow are represented by a view component and the navigation between the pages by a control-flow.
<task-flow-definition id="sample_task_flow1"> <default-activity>sampleF1Page1</default-activity> <input-parameter-definition> <name>serviceName</name> <value>#{pageFlowScope.serviceName}</value> <required/> </input-parameter-definition> <view id="sampleF1Page1"> <page>/sampleF1Page1.jspx</page> </view> <task-flow-return id="returnToCallingPage"> <outcome> <name>returnToCallingPage</name> </outcome> </task-flow-return> <control-flow-rule> <from-activity-id>sampleF1Page1</from-activity-id> <control-flow-case> <from-outcome>closeTaskFlow</from-outcome> <to-activity-id>returnToCallingPage</to-activity-id> </control-flow-case> </control-flow-rule> </task-flow-definition>
The return from a task flow is defined as a task-flow-return element. Note that this does not need to know where the task flow was called from. Of course, that’s necessary for a task flow to be reusable. Every task flow to be used in the application is then defined in adfc-config.xml. A task definition file can be dragged into the adfc-config in design mode. Navigations to a task flow are defined as control flows in adfc-config. These control flows can be anonymous so that they can be used from any JSF page in the application. One thing that I miss (or perhaps couldn’t find) is a sort of return listener that the calling page can register. I can see a lot of potential uses to such a return listener. I will be trying out ADF Task Flows for a feature that I need to build and should have more posts on the subject coming out.