5 ADF Controller Task Flows

This chapter provides a high-level overview of the ADF Controller task flow technology, including its relationship to JSF's built-in controller support. In addition, it describes features and benefits of task flows, including modular and reusable task flows, flows between regions of a single page, transaction management, save points, declarative router decisions, and declarative exception handling.

This chapter includes the following sections:

5.1 About ADF Controller

ADF Controller is a declarative framework that, through the concept of task flows, builds upon the JSF page navigation support represented by the javax.faces.webapp.FacesServlet class and the faces-config.xml file. Figure 5-1 shows how ADF Controller fits into an enterprise application.

Figure 5-1 Overall Application Architecture with ADF Controller

This image is described in the surrounding text

5.2 Core Benefits of ADF Controller

ADF Controller provides the following benefits for developers:

  • Applications can be broken up into a series of modular task flows that call one another.

  • Task flows can contain nodes representing views, method calls, routing conditions, and calls to other task flows. (In a basic JSF application, page flow nodes can only be JSF pages.)

  • You can pass parameters between task activities and different task flows.

  • You can generate a page hierarchy with navigation links for your end users based on the task flow view activities in your application.

  • Task flows are reusable.

  • You can package a task flow into an ADF Library JAR and import it for use in another application's project.

  • Task flows can be called remotely from different ADF applications.

  • Task flows can also be used to secure your Fusion web application by reducing the number of access points that you expose to end users and by enforcing specific access privileges.

5.3 Key Concepts of ADF Controller

ADF Controller's central feature is the task flow. Task flows provide a modular approach for defining control flow in a Fusion web application. Instead of representing an application as a single large JSF page flow, you can break it up into multiple task flows, each of which contains a portion of the application's navigational graph.

A task flow consists of activity nodes, which represent simple logical operations such as displaying a page or page fragment, executing application logic, or calling another task flow. The transitions between the activities are called control flow cases.

Task flows include such features as invocation of custom business logic as part of the page flows, declarative router decisions, declarative exception handling, additional memory scopes, flows within pages, and reusable flows. Task flows also include built-in support for using flows to demarcate transaction boundaries and routing navigation to non-viewable targets such as method calls.

Using JDeveloper, you can create task flows visually using a diagram editor.

5.4 Key Components of ADF Controller

ADF Controller consists of the key components that are described in the following sections:

5.4.1 Unbounded Task Flows

A Fusion web application always contains a single ADF unbounded task flow, which contains the application's entry point, meaning any view activities that can be directly requested by a browser. An application's unbounded task flow can also contain other view activities (including pages with bookmarkable URLs), control flow rules, and calls to bounded task flows.

However, unbounded task flows cannot accept or return parameters or serve as transaction boundaries.

A typical application is a combination of the unbounded task flow and one or more bounded task flows. For example, JDeveloper, by default, creates an empty unbounded task flow (source file name is adfc-config.xml) when you create an application using the Fusion Web Application template. At runtime, the Fusion web application can call bounded task flows from activities that you added to the unbounded task flow.

5.4.2 Bounded Task Flows

Bounded task flows are private task flows that can be called from an unbounded task flow or from another bounded task flow. A bounded task flow has a single entry point and zero or more exit points. It contains its own set of private control flow rules, activities, and managed beans. It allows reuse, parameters, transaction management, reentry, and can render within an ADF region in a JSF page or page fragment. Figure 5-2 shows an example of a bounded task flow as it appears in the diagram editor.

Unlike unbounded task flows, bounded task flows cannot contain bookmarkable view activities.

Figure 5-2 ADF Bounded Task Flow

This image is described in the surrounding text

5.4.3 Task Flow Activities

Each task flow consists of some of the following actions and control cases:

  • Views, which displays a JSF page or page fragment.

  • URL views, which enable you to redirect the root view port (for example, a browser page) to any URL-addressable resource, such as bounded task flows, view activities in the unbounded task flow, and addresses external to the current web application.

  • Routers, which route control to activities based on the runtime evaluation of EL expressions.

  • Method calls, which allow you to call custom or built-in methods that invoke application logic from anywhere within an application's control flow.

  • Task flow calls, which enable you to call a bounded task flow from either the unbounded task flow or a bounded task flow. A task flow call activity allows you to call a bounded task flow located within the same or a different application.

  • Task flow returns, which enable you to identify the point in an application's control flow where a bounded task flow completes and sends control flow back to the caller.

  • Save point restores, which enable you to restore a previous persistent save point in an application supporting save for later functionality. A save point captures a snapshot of the Fusion web application at a specific instance. Save point restore enables the application to restore whatever was captured when the save point was originally created. For more information, see Save Points.

  • Parent action activities, which allow a bounded task flow running in an ADF region to generate outcomes that it passes to the parent view activity. The outcomes are used to navigate the task flow containing the parent view activity rather than navigating the task flow of the ADF region.

  • Control flow cases, which define how control passes from one activity to another in a task flow. A control flow rule can contain one or more control flow cases to identify the activity to which control flow passes.

    Control flow rules are based on JSF navigation rules, but provide additional features. Whereas JSF navigation is always between pages, task flow control flow rules can also handle transitions between other activities, such as method calls and entry and exit points of bounded task flows.

  • Wildcard control flow rules, which enable you to use a wildcard expression to specify which view activities are to be passed to a given control flow rule.

5.4.4 Task Flow Templates

Task flow templates are a construct that help simplify creation of bounded task flows, help enforce consistent runtime behavior of task flows, and make it easier to refactor an application's task flows.

As their name implies, task flow templates are a mechanism for creating standard task flow types. A bounded task flow created from a task flow template will have definitions for the same set of task flow activities, control flows, input parameters, and managed beans as the task flow template. You can create task flow templates for yourself or other application developers to use as a starting point when creating new bounded task flows.

In addition, you can use task flow templates at runtime. When you create a task flow (or another task flow template) based on a template, you can maintain an association between the newly created flow or template and the base template by selecting the Update the Task Flow When the Template Changes checkbox. If you do so, subsequent changes that you make to the base template (such as adding new view activities) get propagated to the child flows (or templates) at runtime. (If there are conflicts between the child and parent, the child overrides the parent.) You can change, update, or disassociate the parent task flow template of a child bounded task flow or task flow template at any point during development of the child.

5.4.5 Save Points

You can add a save point to a task flow to capture the state of a Fusion web application at a particular instance. This allows you to save application state if, for example, a user leaves a page without finalizing it. The application state can be restored at a later point. The saved information includes the following:

  • UI state of the current page, including selected tabs, selected checkboxes, selected table rows, and table column sort order

  • State information saved in memory scopes, including session and page flow scope.

  • The state of serializable managed beans

  • The navigation state, which is derived from the task flow call stack, which tracks where the end user is in the application and the navigation path for getting there

  • The ADF Model state, which consists of any data model updates made from when the current bounded task flow begins

5.4.6 Integration with pageFlowScope, backingBeanScope, and viewScope

ADF Faces provides pageFlowScope, backingBeanScope, viewScope shared memory scopes to augment standard JSF memory scopes.

Of particular relevance to task flows is pageFlowScope, which defines a unique storage area for each instance of a task flow. The pageFlowScope scope begins when the task flow begins and ends when the task flow ends.

For example, a managed bean with pageFlowScope can be accessed within the task flow, even if its activities are spread across different pages. However, it is out of scope for anything outside of that task flow, including other task flows that call its task flow and UI components that are on the same page but in a region that is encompassed by a different task flow.

For more information on these scopes, see Key Concepts of ADF Faces.

5.4.7 Integration with the ADF Faces Train Component

When you create task flows, you can specify that they use the ADF Faces train and trainButtonBar components to guide users through the steps specified by the task flow. Figure shows a page fragment from the Summit sample application for ADF Task Flows that renders these components.

Figure 5-3 ADF Train Component

This image is described in the surrounding text

5.4.8 Integration with the ADF Faces Region Component

When you add a bounded task flow to JSF page or page fragment, it is wrapped within a region tag.

5.5 Overview of the ADF Controller Process Flow

Using ADF Controller consists of the following basic steps:

  1. In JDeveloper, create an application workspace for the application.

  2. Using wizards in JDeveloper's New Gallery, create task flow files.

  3. Using JDeveloper's diagram editor for task flows, design the task flow by adding task flow activities (view activities, method call activities, and so on) and control flow cases.

    As part of this process, you can create the pages that are used in the task flow from scratch, or you can drag and drop existing JSF pages or page fragments to the diagram editor to create view activities in the task flow.

  4. Test run the task flows using the Integrated WebLogic Server from within JDeveloper.

5.6 Learning More About ADF Controller

The following resources provide detailed information about using ADF Controller in applications: