d e v e l o p e r FRAMEWORKS
BY STEVE MUENCH
Developing a Regional Accent
Use task flows as regions to improve UI reuse.
y last column (“Task and
You Shall Receive,” in the
September/October 2008
issue) examined the basics
of the new task flow feature in Oracle
JDeveloper and Oracle Application
Development Framework (Oracle ADF)
11g, which lets you assemble complex
UIs from simpler units. I discussed two
basic types of task flows: bounded, when
the task flow behaves like an encapsulated function call, and unbounded,
when users can start at any page in the
flow. Each view activity I demonstrated
last time corresponded to a distinct
JavaServer Faces (JSF) page, resulting
in a more powerful, declarative way to
sequence pages and application logic.
In this column, I’ll show you how to
create reusable UI components called
regions. Think of regions as components
with view activities that represent only a
fragment of a JSF page and whose visual
contents and runtime behavior are determined by a bounded task flow. Then I’ll
show how easy it is to reuse a region,
embedding it in the contents of another
page. By the end, you’ll appreciate how
this capability enables you to create
reusable UI components using the full
declarative functionality of task flows.
To begin, download the starter
workspace at otn.oracle.com/oramag/
oracle/08-nov/o68frame.zip and ensure
that you’re using the Oracle JDeveloper
11. 1. 1.0 (production) release, available as a free download on Oracle
Technology Network (OTN) at otn
. oracle.com/products/jdev/11. Start
by extracting the contents of the
o68frame.zip file and opening the
FrameworksNovDec2008.jws workspace in Oracle JDeveloper. The Model
project in the workspace defines an
Emp entity object, an EmpView view
object, and an HRModule application
module with a view instance named
Employees. The ViewController project
contains a BrowseEmployees.jspx page
whose af:panelStretchLayout component contains an af:table in its left facet,
showing employee numbers and names.
Before proceeding, adjust the properties of the connection named scott in
the Application Resources zone of the
Oracle JDeveloper Application Navigator
until you can successfully test a connection to a SCOTT schema. If you need
to create the tables, use the provided
CreateDeptEmp Tables.sql script.
The steps in this column will enable
you to create a Show Employee Details
region and drop it into the center facet
of this page to reuse it. The final application will allow you to select an employee
from the table and display the corresponding details for that employee in the
new task flow region.
CREATING A BOUNDED TASK FLOW OF
PAGE FRAGMENTS
In the last column, we configured a few
task flows that already existed in the
starter project, so this time let’s walk step
by step through creating a new task flow,
adding view and method activities, configuring input parameters, and marking
a default activity. Although the example
is intentionally simple, it will nonetheless familiarize you with all the key concepts you need to know to create your
own reusable regions. Task flows that
are destined to be reused as embeddable
regions must be bounded and must
comprise JSF page fragments, because
at runtime their contents become a part
of the page (or other fragment) that
contains them. So let’s start by creating a
new bounded task flow.
With the sample workspace,
FrameworksNovDec2008.jws, open in
the Application Navigator, right-click
the ViewController project and choose
New.... In the New Gallery dialog box
that appears, select Web Tier -> JSF
and then double-click ADF Task Flow.
When the Create Task Flow dialog box
appears, enter show-emp-details.xml as
the filename, leaving the default settings
for the other fields. Note that the check
boxes for Create as Bounded Task
Flow and Create with Page Fragments
are checked by default. These are the
precise options required to create a
region. Click OK to create the new task
flow. Oracle JDeveloper opens the visual
editor for this new task flow and displays the Diagram view.
Next, we’ll add the components of
our region by dragging them onto the
diagram. Drag a view activity from the
Component palette and drop it onto
the design surface. When the view
activity shape appears, type directly on
the diagram to change its name from
view1 to ShowEmployee. Double-click
the ShowEmployee view activity to
create its JSF page fragment. When the
Create New JSF Page Fragment dialog
box appears, accept the default settings
and click OK to continue. The visual
editor will open for the ShowEmployee
.jsff page fragment, showing an empty
canvas. Expand the Data Controls
section of the Application Navigator as
well as HRModuleDataControl, and
drag the Employees data collection
onto the page. When the Create context
menu appears, select Forms -> ADF
Read-only Form.... When the Edit Form
Fields dialog box appears, click OK to
create the form with all of the items.
Next, we’ll enhance the task flow to
accept a parameter named Empno and
then to look up the employee row to
display, based on the value of that Empno
parameter. Select the show-emp-details
.xml tab to activate the task flow design