
When you work in JDeveloper, you organize your work in projects within an application. JDeveloper provides several templates that you can use to create an Application and projects. The templates are pre configured with a basic set of technologies that are needed for developing various types of applications, and you create your working environment by selecting the template that fits your needs. You can then configure it to add any other technologies you plan to use.
In the first section you are going to create a new Application using the Fusion technology and build reusable business components that will access the database. To create the application and the model components, perform the following steps:
In the Applications Navigator, click New Application. Another option is to use the File->New... menu option to create a new application.
-
In the New Gallery, select the Fusion Web Application (ADF) option. This option creates a data bound ADF web application. The application consists of two projects, one for the data model (ADF-Business Components) and the other for the view controller components (ADF Faces and ADF Task Flows).
-
In the Create Fusion Web Application dialog box, specify the Application Name to be TaskFlow. Notice that the directory changes to match the new name. You can change the C:\JDeveloper\mywork part of the path to create your files in another location.
In the Application Package Prefix field set the value to be demo. In the Application Templates choose the Fusion Web Application (ADF) and click Finish.
The Overview pane displays a Checklist you can refer to as a guide for developing a Fusion Web Application.
The Checklist is displayed by default when a Fusion Web application is created.
-
Examine the Application Navigator and you'll see two new projects now. The default naming rules for these projects are Model for one and ViewController for the other.
-
We start creating the model components using the CheckList Overview. Click the Connect to a Database step.
You use the Initialize Business Components Project dialog to select a design time application resource connection to use while working on your business components in this data model project or to create a new application resource connection by copying an existing IDE-level connection.Read more...
-
The step expands showing useful information such as prerequisites required for performing this task. Click the Create a Database Connection button.
-
Specify the following properties for the new connection you are creating:
Enter the Oracle JDBC Settings properly to point to the right host, port and SID for your database. Click the Test Connection button and verify that you got success.
Once done, click the OK button.Property Value Connection Name HRConn Username hr Password hr
-
In the Checklist pane, set the status of the Connect to a Database step to Done.
-
Click the Build Business Services step to expand it, then click the Go to Sub steps button.
-
In the sub task list, click the Create Entity Objects and Associations sub task.
Then click the Create Entity Objects and Associations button.
An entity object is the ADF Business Components component that represents a row in the specified data source and controls modifying its associated attributes.Read more...
-
In the Select Project for Action dialog, select the Model project.
Click OK. -
In the Initialize Business Components Project dialog the HRConn connection should be selected. Then click OK.
-
In the Entity Objects page, click the Query button to examine the data dictionary and see available tables.
-
Select the EMPLOYEES table in the Available list, and click the right arrow
to move your selections to the Selected list. This step creates updatable Entity Objects based on the tables you chose.s
Then click Next to continue. -
In the Updatable View Objects dialog, move Employees (HR.EMPLOYEES) to the Selected list. This step creates matching view objects to perform queries on the entity object you created before.
Then click Next to continue. -
In the Read Only View Objects dialog, Click Next to continue.
A view object is an Oracle Application Development Framework (Oracle ADF) component that encapsulates a SQL query and simplifies working with its result.Read more...
-
In the Application Module dialog, click Finish to create the business components in the Model project.
An application module is an ADF Business Components component that encapsulates the business service methods and UI-aware data model for a logical unit of work related to an end-user task.Read more...
-
In the Checklist, set the status of the Create Entity Objects and Associations step to Done. Then click the Close Step 3 button.
Note: Since steps 3.2, 3.3 and 3.4 have also been completed, we could as well set their status to done, but we'll do it at a higher level. -
Set the status of the Build Business Services step to Done.
-
The work on the model project is performed. Expanding the Model project, the Application Navigator should look like the following:
-
Click the Save All
icon on the JDeveloper menu bar, or select File | Save All from the menu.
Next we'll work on the ViewController project.
With the TaskFlow application loaded in JDeveloper, you create a bounded task flow diagram including views, and returns. To do this, perform the following steps:
-
In the Application Navigator, right click the ViewController node and select New from context menu.
An ADF bounded task flow is used to encapsulate a reusable portion of an application.Read more...
-
In the New Gallery, click the Web Tier | JSF/Facelets node and select ADF Task Flow.
-
In the Create Task Flow dialog, type emp-update-flow as the File Name. Select the following checkboxes.
Then click OK.Property Value Create as Bounded Task Flow Checked Create with Page Fragments Checked Create Train Checked -
A new empty task flow diagram displays and a new entry is created in the Application Navigator.
-
Select the View component
from the Component Palette and drag and drop it onto the diagram surface.
The primary type of task flow activity is a view, which displays a JSF page or page fragment.Read more...
-
Change the default name to intro.
-
Create a new view
on the diagram next to the intro one.
Rename it search. -
Create a third view
on the diagram.
Rename it update. Your diagram should look similar to the image below.
-
Save all your work.
The intro page is the entry point of this task flow and you'll see how to create a train within the pages. To do this, perform the following steps:
-
On the emp-update-flow diagram, double click the intro view component to create the page.
In the Create New JSF Page Fragment dialog, click OK to accept default values. -
The page design pane opens up. From the Component Palette, in the ADF Faces Common Components group, select the Train component
and drop it onto the page design surface.
A train represents a progression of related activities that guides an end user to the completion of a task.Read more...
In the Bind Train dialog, click OK to accept the default value.
-
Select the Train Button Bar component
and drop it underneath the Train component.
In the Bind trainButtonBar dialog, click OK to accept the default value.
-
From the Component Palette, in the ADF Faces General Components group, select the Output Text component
and drop it underneath the Train Button Bar.
Open the Property Inspector if not already there (View | Property Inspector or use the key combination [Ctrl] + [Shift] + [I]), and enter Welcome to the Employee updater in the value field.
The page should look like this:
-
Save all your work and then click the emp-update-flow tab to reopen the task flow diagram.
-
Double click the search view component to create the search page.
-
In the Create New JSF Page Fragment dialog, click OK to accept default values.
-
The page design pane opens up. From the Component Palette, in the ADF Faces Common Components group, select the Train component
and drop it onto the page design surface.
In the Bind Train dialog, click OK to accept the default value.
-
Select the Train Button Bar component
and drop it underneath the Train component.
In the Bind trainButtonBar dialog, click OK to accept the default value.
-
Save all your work, and then click the emp-update-flow tab to reopen the task flow diagram.
-
Double click the update view component to create the update page.
-
In the Create New JSF Page Fragment dialog, click OK to accept default values.
-
The page design pane opens up. From the Component Palette, in the ADF Faces Common Components group, select the Train component
and drop it onto the page design surface.
In the Bind Train dialog, click OK to accept the default value.
-
Select the Train Button Bar component
and drop it underneath the Train component.
In the Bind trainButtonBar dialog, click OK to accept the default value.
-
Click the Save Allicon to save the application.
The search and update pages need to bind data control components. The search page for querying employees on any column criteria and the update page for displaying and updating an employee's salary. To do so, perform the following steps:
-
Click the search tab to reopen the page.
-
In the Application Naviator o pen the Data Controls accordion and expand the following nodes AppModuleDataControl | EmployeesView1 | Named Criteria and drag and drop the All Queriable Attributes on the page.
A data control is essentially a bridge that makes data from a source, available to the user interface, in an ADF Fusion Web Application.Read more...
From the pop up menu, select Create | Quick Query --> ADF Quick Query with Table option.
A quick query search form is intended to be used in situations where a single search will suffice or as a starting point to evolve into a full query search.Read more...
-
In the Edit Table Columns dialog, select the Single Row Selection and Enable Sorting options.
Then click OK. -
The page should look like the following:
-
Click the update tab to open the page.
-
From the Data Controls pane, select AppModuleDataControl | EmployeesView1 then drag and drop it onto the update page.
-
From the pop up menu select Create | Form --> ADF Form option.
Dropping an object as a form from the Data Controls panel has the same effect as dropping a single attribute, except.Read more...
-
the Edit Form Fields select the last 3 rows (CommissionPct, ManagerID and DepartmentId) and click the Delete button
to discard the fields. Then select the Include Submit Button option and click OK.
-
In the Component Palette, select the Button icon
and drag and drop it next to the Submit button.
-
In the Property Inspector, type Cancel in the Text field for the button.
-
The page should look like the following:
-
Click the Save All
icon to save the application.
To end a transaction, you can either use a return activity or you can use a button bound to an operation action. If possible, use a task flow return activity. Using a task flow return activity will commit all the data used in views on the ADF task flow. It also makes it easier to see where your application is doing commits and rollbacks, and is therefore easier to maintain. To implement return activities for transaction controls, perform the following steps:
-
Click the emp-update-flow tab to reopen the task flow diagram.
-
Click the Overview tab and then select the Behavior tab.
-
In the Transaction group, set the following properties from the list: Always Begin New Transaction.
A transaction is a persisted collection of work that can be committed or rolled back together as a group.Read more...
This way, each individual employee update is seen as a single row granularity transaction.
-
Back in the diagram, select the Task Flow Return component
and drop it underneath the update view.
Rename it commit.
-
Select again the Task Flow Return component
and drop it underneath the update view. Rename it rollback. .
-
Select the Control Flow Case component
from the Component Palette and clicking in the update view, drag and drop it into the commit return.
Rename it commit.
-
Select the Control Flow Case component
from the Component Palette and clicking in the update view, drag and drop it into the rollback return. Then rename it rollback.
-
The task flow diagram should look like the following:
-
Select the commit return component and in the property inspector, in the Behavior tab, for the End Transaction field, select commit, from the list of values.
-
Repeat the same operation selecting the rollback return and select rollback from the list for the End Transaction field.
-
Click the Save All
icon to save the application.
-
Click the update tab to open the update page design, and select the Submit button.
In the Property Inspector, in the Action field, select commit from the list.
-
Select the Cancel button.
In the Property Inspector, in the Action field, select rollback from the list.
-
Click the Save All
icon to save the application.
We want to restrict the access to the application through a login process. We create a login page, a router, an error page and the previously created task flow. To create this task flow, perform the following steps:

-
In the Application Navigator, right click the ViewController node and select New from context.
-
In the New Gallery, click the Web Tier | JSF node and select ADF Task Flow. Then click OK.
-
In the Create Task Flow dialog, type security-flow as the File Name. Select the the Create as Bounded Task Flow and Create with Page Fragments checkboxes.
Click OK. -
A new empty task flow diagram displays and a new entry is created in the Application Navigator.
-
Select the View component
from the Component Palette and drag and drop it onto the diagram surface.
Rename the view login.
-
Select the Router component
and drop it next to the login view.
You can use a router activity to declaratively route control to activities based on logic specified in an EL expression.Read more...
-
Select the emp-update-flow in the Application Navigator then drag and drop it on the diagram below the router.
-
Select the View icon
from the component palette then drag and drop it on the diagram surface.
Rename the View to error.
-
Select the Control Flow Case icon
and clicking in the login view, drag the flow into the router.
-
Repeat the previous operation to draw a Control Flow Case
from the router to the error view.
Rename the flow to bad.
-
Repeat the previous operation to draw a Control Flow Case
from the router to the emp-update-flow view.
Rename it to good. -
Repeat the previous operation to draw a Control Flow Case
from the error view to the login view.
Rename the flow login. Your diagram should look like the following: -
The second task flow is complete. Click the Save All
icon to save the application.
We create a login page with a password field, then we create a backing bean for the password value. Then the router, depending on the password value, leads to an error page or to the emp-update flow. To create the pages and implement the router rules, perform the following steps:
-
In the diagram, double click the login view icon to create the page. In the Create New JSF Page Fragment, click OK to accept default values.
-
In the Component Palette, drag and drop an Input Text icon onto the login page.
Enter password as the label.
-
In the Advanced tab, next to the Binding field, select Edit from the drop down list.
In the Edit Property dialog, click the New button to create a Managed Bean to hold the password value.
Managed beans are Java classes that you register with the application using various configuration files.Read more...
In the Create Managed Bean dialog, enter the following values:
Property Value Bean Name backing_login Class Name backing_login Package backing Extends java.lang.Object Scope request Generate Class If It Does Not Exist (checked)
Click OK.
-
Back in the Edit Property, click the New button next to the Property field.
In the Create Property dialog, enter password as the Property Name.
-
The Advanced node, in the Property Inspector, for the input text component should look like the following:
Notice that for a realistic password field, you would also set the Advanced | Visible property to false to hide the typed password value. -
Drag and drop a Button component
underneath the password field.
Change the Text property to login.
-
Click the security-flow tab to open the task flow diagram and add a Control Flow from the error page to the login page and name it login.
Then select the router. -
In the Property Inspector for the router, select bad from the drop down list as the default outcome.
In the Cases click the Add buttonto create a condition.
-
In the Expression field select the Expression Builder option from the list.
Expand the following nodes ADF Managed Beans | backing_login | password and select the value variable, then select the '==' operand and type 'oracle'.
Click OK.
In this example we have coded oracle as a hard coded value for the password.
-
Back in the Property Inspector, select good as the outcome, so that if the password entered is equal to oracle, the flow takes you through the 'good' flow to the emp-update flow, otherwise to the error page.
-
Now we need to create a parameter to work the managed property value. In the security-flow diagram, click the Overview tab and then the Parameters tab.
A called ADF bounded task flow can accept input parameters and can pass return values to the caller upon exit.Read more...
-
In the Input Parameter Definitions, click the Add button
.
-
Set the parameter to the values from the table below, then save all your work.
Property Value Name username Class java.lang.String Value (auto populated) Required (Checked) -
Click the login.jsff tab to open the page,and drag and drop an Output Text component above the password input text.
-
In the Property Inspector, select the Expression Builder... option from the Value field list.
In JSF, you use a simple expression language (called EL) to bind to the information you want to present and/or modify.Read more...
-
In the Expression Builder make sure to clear out the expression field, then expand ADF Managed Beans | pageFlowScope and select username.
Then click OK. -
Click the security-flow tab to open the task flow diagram and double click the error view to create the page.
In the Create New JSF Page Fragment dialog, click OK to accept default values.
-
From the Component Palette, drag and drop an Output Text
onto the page.
In the Property Inspector, enter Error, wrong password in the Value field.
-
In the Design, press Enter to add a new row and drag and drop a Button component
underneath the error text.
In the Property Inspector, change the Text field to Retry, and from the list, select login as the action.
-
Click the Save All
icon to save the application.
To create JSF Page that uses the task flow, perform the following steps:
-
Right click the ViewController node in the Application Navigator and select New from context.
-
In the New Gallery, select Web Tier JSF as the Category and JSF/Facelets and Page as the Item.
Then click OK. -
In the Create JSF Page dialog, enter master as the File Name and checking the Page Template option, select the Oracle Three Column Layout.
Then click OK. -
Scroll around to see the displayed page in the editor.
-
From the Component Palette, drag and drop an Output Text component
onto the start facet.
Change the Value field to Welcome in the Property Inspector.
-
In the ViewController | Web Content | WEB-INF node, drag and drop security-flow.xml onto the Facet center.
Select Region from the menu.
You can render a bounded task flow in a JSF page or page fragment (.jsff) by using an ADF region.Read more...
In the Edit Task Flow Binding, in the Value field, enter #{'Scott'}.
-
The master page should now look like the following:
-
Click the Save All
icon to save the application.
Now that the task flow is integrated as a region to the master page you can run it. To do this, perform the following steps:
-
In the editor for the master page, right click and select Run from context..
-
The page loads up in your browser displaying the username variable (Scott) and waiting for a password to be typed in.
-
Try entering a wrong password value (different from oracle).
Then click the login button. The router drives you to the error page. -
Click the Retry button to logon with the correct password.
-
Back in the login page, enter oracle as the password value.
Then click login.
-
The new page appears displaying the train.
-
In the new page, click the Next button or the second button on the train.
-
In the second step of the train, in the search page, select LastName.
Enter A% in the search field to retrieve all employee's name starting with an A.
Click the search button. -
In the returned list, select one employee of your choice and then click the Next button.
You can collapse the Search panel, until you are ready to enter new criteria.
-
In the Edit page for the selected employee, update the salary to the value of your choice, then click Submit.
-
The application takes you back to the login page.
-
Switch back to JDeveloper and open the Database Navigator (if not visible, use View | Database | Database Navigator).
-
Expand the TaskFlow | HRConn | Tables nodes and double click the Employees table to open it.
-
Click the Data tab to display employee's values.
Click the Sort button.
-
To retrieve more easily the information about the employee you're looking for, you can use the Filter field or use a Sort operation. Click the Sort button and in the Sort Columns dialog, move LAST_NAME in the Selected Columns pane.
Then click OK. -
Locate the employee you've updated the salary to confirm that the update is committed with the new value.
-
You can reiterate this last process to test the Cancel (rollback) action.
You've successfully completed this tutorial.
- Create the Model Components
- Create a bounded task flow diagram
- Build the task flow pages
- Bind the task flow pages to data controls
- Set the transaction control to the task flow
- Define a second task flow
- Define the task flow components and the router rules
- Create the JSF Page and Bind the Task Flow as a Region to the page

