You will use wizards to quickly create an application and
projects, and a blank ADF bounded task flow for each train. The first
train you
will create consists of four pages (or train stops) that guide an end
user to the completion of a task. The second train you will create
consists of two pages in a multistep subtask. The second train will
be called from one of the train stops in the first train sequence.
Step 1: Create a New Application and Projects
- From the main menu, choose File > New. In the New
Gallery, expand the General category and select Applications.
Then in the Items list, select Fusion Web Application (ADF) and click OK.
- To follow along with the example, enter
TrainWebApp
as the application name.
- Accept the defaults and click Finish.
The Application Overview window opens by default in the editor window area when you create a new application. You can optionally close the window, since you will not be using it to create objects for this application.
The JDeveloper application is the highest level in the
organizational structure. While you are developing your application,
it stores information about the objects you are working with.
Read more...
The application template you select determines the initial project
structure, that is, the named project folders within the
application workspace, and the application libraries that will be
added.
All objects that you create within JDeveloper appear in the
Application Overview file summary pages, arranged by object type.
You can create new files and artifacts, and view them filtered by
status and project.
Step 2: Create a Task Flow for Each Train
-
In the Application Navigator, right-click the ViewController project and
choose New > Web Tier > JSF/Facelets > ADF Task Flow, then click OK.
-
In the Create ADF Task Flow dialog, enter or select the following values:
Field or Option Value File Name train-flow.xml
Create as Bounded Task Flow selected Create with Page Fragments selected Create Train selected
- Click OK.
By default JDeveloper displays the new bounded task flow in the diagrammer.
-
In the Component Palette, ADF Task Flow page, Components panel, drag and drop View on the diagrammer, then rename the activity. Do this four times, using the following activity names:
start
addresses
payment
review
-
Drag and drop Task Flow Return on the diagram. Accept the default name of
taskFlowReturn1
.
-
In the Component Palette, click Control Flow Case. On the diagram, click the review icon, then click the taskFlowReturn1 icon. Rename the control flow case element to
commit
.
-
In the Structure window, expand view - start. Right-click train-stop and choose Insert Inside train-stop > Display Name.
-
In the Property Inspector, enter
Start
in the Display Name field. -
Repeat the procedure in steps 7 and 8 to add train stop display
names to the remaining three view activities, using the following Display Name values:
Addresses
Payment
Review
- In the Application Navigator, right-click the ViewController project and
choose New > Web Tier > JSF/Facelets > ADF Task Flow, then click OK.
-
In the Create ADF Task Flow dialog, enter or select the following values, then click OK.
Field or Option Value File Name childtrain-flow.xml
Create as Bounded Task Flow selected Create with Page Fragments selected Create Train selected
-
In the Component Palette, drag and drop View on
the diagrammer, then rename the activity to
billing
. Repeat the procedure to add one more view activity, using the nameshipping
. - Drag and drop Task Flow Return on
the diagram. Change the name to
childFlowReturn1
.
- Draw a Control Flow Case from shipping to childFlowReturn1. Rename the case element to
done
. -
In the Structure window, expand view - billing. Right-click train-stop and choose Insert Inside train-stop > Display Name. In the Property Inspector, enter
Billing
in the Display Name field.
-
Repeat the procedure in step 15 to add a display name to the remaining view activity, using the Display Name value
Shipping
.
- Click Save All to
save your work.
ADF 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 a collection of reusable task flows.
A train represents a progression of related activities that guides an end user to the completion of a task.
Only a bounded task flow that specifies the
<train/>
element in its metadata can be used to define a
train task flow.
The red error icons on the diagram indicate that the view
activities are not yet associated with any physical page files.
Like any bounded task flow diagram, you use a task flow return activity to indicate an exit point for the train flow and
return control back to the caller.
The
<train/>
element is automatically added for you by JDeveloper when you check the Create Train box in
the Create Task Flow dialog.
When you complete the steps for creating two bounded task flows as trains, the ViewController
project in the Application Navigator should look something like this,
Step 3: Add a Task Flow Call to a Train
- In the editor window, click the train-flow.xml document tab to bring the diagram forward.
(If not already open, double-click train-flow.xml in the Application Navigator to open the diagram.)
- In the Application Navigator, under Page Flows in the ViewController project,
drag childtrain-flow to the diagram and then drop it beneath the addresses icon.
-
On the diagram, right-click the review icon and choose Train > Move Backward.
-
Then right-click the payment icon and choose Train > Move Backward.
The diagram should now look like this:
- In the Component Palette, click Control Flow Case.
On the diagram, click the childtrain-flow icon, then click the payment icon.
Accept the default element name of
childFlowReturn1
.
-
On the diagram, select the payment icon. In the Property Inspector, Train Stop section, enter
false
in the Sequential field.
-
In the Structure window, expand task-flow-call - childtrain-flow. Right-click train-stop and choose Insert Inside train-stop > Display Name.
-
In the Property Inspector, enter
Child train
in the Display Name field.
- Click Save All to save your work.
A bounded task flow containing a train can use a task flow call activity to invoke a child bounded task flow representing
another train.
A task flow call activity acts like a train stop, executing the default activity in the called task flow first.
By default all train stops, including task flow calls acting as train stops, behave as sequential.
When you call
childtrain-flow
in the parent train-flow
, you have to manually wire a
control flow case to return from the child train.
By default all train stops behave as sequential. In the Property Inspector, you can set the Sequential option on the view activity for a train stop to specify whether it has sequential or nonsequential behavior.
In the Structure window of
train-flow.xml
, the task-flow-call - childtrain-flow element should look like this when all its nodes are expanded:
Step 4: Create an ADF Page Template
-
In the Application Navigator, right-click the ViewController project and
choose New > Web Tier > JSF/Facelets > ADF Page Template, then click OK.
- In the Create ADF Page Template dialog, enter
traintemplate.jsf
in the File Name field.
- Confirm that Facelets is selected as the document type, and Use a Quick Start Layout is not selected.
- With the Facet Definitions tab in front, click to add a facet. Enter
body
in the Name field, then click OK.
- At the top of the editor window, click the document tab traintemplate.jsf to make sure the visual editor is in focus.
-
In the Component Palette, ADF Faces page, Layout panel, drag Decorative Box and drop it on the blank page in the visual editor.
When you drag the component to the visual editor, you should see a target rectangle with the name Page Template Def on the page; this means the component you are dragging will be inserted inside that target. -
In the Component Palette, Layout panel, Core Structure section, drag Facet and drop it into the center facet of the decorative box you just added.
- Choose body from the Facet Name dropdown list, then click OK.
Thebody
facet, defined in the page template definition, allows page authors to add their own content when they create their pages or page fragments using the page template. - Click Save All to save your work.
The visual editor should look similar to this:
If following along with the example, at this point there are no page fragments in the Application Navigator.
A page template is a template definition file written in XML.
This is just an example; it is entirely up to you how you want to arrange your template page layout.
Step 5: Add and Bind a Train Component
-
In the editor window, click the traintemplate.jsf document tab to make sure the
template page is in focus. If necessary, click the Design tab at the bottom to use the visual editor.
-
In the Component Palette, ADF Faces page,
General Controls panel, Location section,
drag
Train and drop it into the top facet of the
decorative box component.
-
In the Property Inspector of the train component, Common section, choose Expression Builder from the dropdown menu next to the Value field.
-
Expand ADF Controller Objects | controllerContext | currentViewPort | taskFlowContext. Then select trainModel and click OK.
- Click Save All to save your work.
The visual editor should look similar to this:
When a task flow consists of a set of pages that end users must visit in a particular order, use the ADF Faces Train
component to display a progression of the related activities that guides end users to the completion of the task.
The ADF Faces Train component enables end users to navigate
through the train stops in an order specified in the underlying
train model.
This is just an example; it is entirely up to you how you want to arrange your page layout, and where you want to place
the Train component.
Step 6: Create the Page Fragments for the Views
- In the editor window, click the train-flow.xml document tab to bring the diagram forward.
- On the diagram, double-click a view icon (for example, start) to open the Create ADF Page Fragment dialog.
- Accept the default file name (for example, start.jsff) and make sure Facelets is the selected document type.
- On the Page Layout page, select Page Template and then
select traintemplate from the dropdown list.
-
Click Managed Bean and then select Do not Automatically Expose UI Components in a Managed Bean.
- Click OK.
JDeveloper displays the page fragment in the visual editor. The Train component from the page template should be visible on the page.
-
In the visual editor, add contents to the page by inserting ADF Faces components into the body facet.
To follow along with the example, in the Component Palette, ADF Faces page, Layout panel,
Interactive Containers and Headers section, drag Panel Header
and drop it into the body facet on the page. Then insert an output text component into the panel header component.
-
Repeat steps 1 through 7 for each remaining view icon on the
train-flow
diagram.
- In the editor window, click the childtrain-flow.xml tab to bring the diagram forward.
-
Repeat steps 2 through 7 for both view icons on the
childtrain-flow
diagram to create the page fragments.
- In the editor window, click the billing.jsff tab to bring the page forward.
- In the Component Palette, ADF Faces page, General Controls panel,
Location section, drag Train Button Bar
and drop it into the menuBar facet of the panel header component on the page.
If following along with the example, you would have added the panel header component as described in step 7.
- Accept the EL expression of
#{controllerContext.currentViewPort.taskFlowContext.trainModel}
and click OK.
- In the editor window, click the shipping.jsff tab to bring the page forward.
- In the Component Palette, Layout panel, drag Panel Group Layout and drop it into the menuBar facet of the panel header component.
- In the Property Inspector, Common section, select horizontal from the Layout dropdown list.
- In the Component Palette, General Controls panel, Location section, drag Train Button Bar and drop it into af:panelGroupLayout - horizontal in the Structure window.
- Accept the EL expression of
#{controllerContext.currentViewPort.taskFlowContext.trainModel}
and click OK.
- In the Component Palette, General Controls panel, drag Button and drop it into af:panelGroupLayout - horizontal in the Structure window.
-
In the Property Inspector of the button component, Common section, enter
Return to parent flow
in the Text field. Then select done from the Action dropdown list.
- Click Save All to save your work.
The buttons on theshipping.jsff
page, which includes a Train Button Bar component with its Back and Next buttons, should look similar to this:
If following along with the example, at this point there are no page fragments in the Application Navigator.
In the Create ADF Page Fragment dialog, you can optionally
specify
whether or not components on the page are exposed in a managed bean,
to allow programmatic manipulation of the UI components.
After creating a page fragment based on the template, you can add
contents specific to the page you are creating by inserting
appropriate ADF Faces components into the
body
facet.
After creating all the pages from the
train-flow
diagram,
The Train Button Bar component is bound to the same train model as the Train component on the template.
At runtime, after users navigate into the child train flow pages,
they need a way to navigate back to a parent train page.
The af:panelGroupLayout component in the Structure window of
shipping.jsff
should look like this:
Step 7: Invoke a Train Task Flow from a Region
- In the Application Navigator, ViewController project, double-click adfc-config under Page Flows to open the default page flow diagram.
-
In the Component Palette, ADF Task Flow page, Components panel, click View then click on the diagram to add a page icon. Change the default page name to
main
. - On the diagram, double-click the page icon you just added to open the Create JSF Page dialog.
-
Select Facelets as the document type and accept the default file name of
main.jsf
.
-
On the Page Layout page, select Quick Start Layout, then click Browse.
-
In the Component Gallery, select the Two Column category on the left. Then on the right, select the fourth type and the fifth layout.
You should see Two Column Left, Header (Stretched) under Options on the right.
- Select Apply Themes, then click OK.
The Create JSF Page dialog should now display the quick start layout selection you made: - Click Managed Bean and select Do Not Automatically Expose UI Components in a Managed Bean. Then click OK.
JDeveloper displays the page in the visual editor.
-
If you wish, you may go directly to step 14 to insert the
train flow as a region, then run the page. Otherwise you may continue
with the optional layout steps 10 through 13.
- In the Component Palette, ADF Faces page, Layout panel,
Interactive Containers and Headers section, drag Panel Accordion and drop it on the start facet in the visual editor. In the Property Inspector, Common section, change DiscloseMany to true.
-
In the Structure window, expand af:panelAccordion. Select the child af:showDetailItem.
- In the Property Inspector, Common section, change the Text value to
Browse
. -
In the Structure window, right-click af:panelAccordion and choose Insert Inside af:panelAccordion > Show Detail Item to add a second pane. In the Property Inspector, Common section, change the Text value to
Search
.
- From the Application Navigator, drag the train-flow node under Page Flows and drop it on the center facet in the visual editor. From the Create context menu, choose Region.
- In the editor window, click the adfc-config.xml tab to bring the diagram forward.
Right-click the main page icon and choose Run.
If the Create Default Domain dialog displays, enter the default password, for exampleweblogic1
, in the Password and Confirm Password fields, then click OK.
When the application is run and the page is first rendered at runtime, the region's content on the page is that of the first view activity on thetrain-flow
diagram:
-
Click the second train stop Addresses to navigate to the next page in the train flow.
While difficult to notice in this simple example, note that navigation to the Addresses view occurs within a region on the page. The content of the region is updated using partial page rendering (PPR).
- Click the Payment train stop to jump ahead to the third stop without entering the child train flow.
This is possible because you set the third stop as nonsequential.
-
On the Payment page, click Addresses again, then click the Child train stop to enter the child train flow.
You should see the first page of the child train flow. A child train flow has an icon representation of the parent train before and after the child train stops. -
Use the Back and Next buttons or the train stops to navigate forward and backward within the child train flow.
- On the Shipping page, click the button to return to the parent train flow.
By default JDeveloper creates an empty unbounded task flow (source file
adfc-config.xml
) when you create a
Fusion web application using the Fusion Web Application template.
ADF Faces provides a number of components that you can use to define the overall layout of a page.
When you use a quick start layout option, JDeveloper adds the components necessary to display the layout.
An ADF region is a UI component whose content is based on a bounded
task flow. To use a task flow as an ADF region within a page, the task
flow must be a bounded task flow that contains
at least one view activity or one task flow call activity to the page
where you want to render the ADF region.
By default, JDeveloper automatically configures an integrated server named Integrated WebLogic Server that references
a user-specific instance of Oracle WebLogic Server bundled with the IDE.
The current stop in the train is indicated by the bold stop icon and display name.
When you exit the child train flow, you should be returned to the Payment page in the parent train.