Defining the page flow
When we talk about defining the page flow of our application, we talk about it in terms of how pages interact with each other, designing what is the right sequence of pages that the user has to navigate through; also, designing how work units are arranged in pages, and how they can be modularized and communicate with each other as well.
In this recipe, we move from the Business Service layer to the Controller layer. In order to work with page flows, we need to first understand what ADF Task Flow is.
ADF Task Flows provide a modularized approach to define the control flow in an ADF application. So, instead of representing an application as a single large page, you can break it up into a collection of reusable task flows.
Each task flow contains a portion of the application's navigational graph and can be considered as a logical business unit of work.
Each task flow contains one or more nodes that are called activities. An activity node can represent a simple logical operation such as displaying a page or a page fragment, executing an application's logic, or calling another task flow.
The transitions between the activities are called control flow cases and can represent navigations between different pages.
There are two types of task flows:
- Unbounded task flows: These are task flows without a specific start point that can contain one or more activities, control flow rules, and managed bean definitions. The application can interact with any activity inside of unbounded task flows without having to take a specific path. Usually, it represents the application's main navigational page model such as the
adfc-config
Task Flow. - Bounded task flows: Unlike the unbounded task flow, a bounded task flow has a single entry point (activity) and zero or more exit points. It has its own private activities, control flows, and Managed Bean definitions. Bounded task flow allows the reuse of parameters, transaction management, re-entry, and routing; it also allows us to save a state and more. Unlike unbounded task flows, it can be rendered within the ADF region inside a JSF Page.
Tip
You can have an overview of task flow and task flow-oriented architecture by watching this great video: http://www.youtube.com/watch?v=TajCHL7Hw5M
In this recipe, we will create one bounded task flow. We won't create any unbounded task flows, but we will be using the adfc-config
task flow later.
How to do it…
In order to create the bounded task flow, follow the ensuing steps:
- Expand the Design Application Flow checklist item and click on the Create a Task Flow button. A pop-up window will pop up asking which project you wish to create this task flow for; choose
ViewController
and click on OK. Another dialog window will pop up asking you to create your task flow. - Name the task flow file
retrieve-employees-information
. The name should be meaningful. It'll be better if you arrange your task flows into different physical directories under theWEB-INF
directory based on their functionalities; however, for my simple application, I'll retain the default setup. - Make sure that the Create as Bounded Task Flow checkbox is checked.
- Uncheck the Create with Page Fragments option and then click on OK.
Once you create your task flow, you should be directed to it; if this doesn't happen, you can easily locate it by navigating to Applications Navigation pane | ViewController | Web Content | Page Flows.
When you open the task flow, you will be directed to the Diagram view asking you to place components from the Components pallet on the right-hand side.
- Expand the Components category under Components palette if not expanded; locate the View activity and drag-and-drop it inside the task flow diagram view.
- Name the newly added View activity
employees
. You can see that there is a green circle around it, which indicates default activity; you will also see a purple triangle over it, which means that this page has not been created yet. - Save everything using Ctrl + S or clicking on the double disk icon on the toolbar.
- Open the HelloADFFaces Overview tab and check the Design Application Flow checklist item as done.
How it works…
In this recipe, we created a simple bounded task flow that has one activity, which represents a View; a View means a page in our case, which will be physically created in the next recipe.