Place
the cursor over this icon to load and view all the screenshots for this tutorial.
(Caution: Because this action loads all screenshots simultaneously, response
time may be slow depending on your Internet connection.)
Note: Alternatively, you can place
the cursor over each individual icon in the following steps to load and view
only the screenshot associated with that step.
Overview
The tutorial uses Oracle JDeveloper 10g to build
an ADF UIX application that contains an LOV. The tutorial demonstrates how easy
it is to create an LOV, and how you can apply a filter to your LOV using Oracle
JDeveloper 10g.
The UIX page that you create in this tutorial will display
employees information based on the "Human Resources" data model. After
creating the Business Services layer, You will create a UIX page showing an
employee record with an LOV displaying the Departments information.
Before starting this tutorial, you should have completed the
following:
1.
Install Oracle JDeveloper 10g.
2.
Install the sample schemas. This example uses the HR schema
included in the Oracle database. The Sample Schemas installation guide
is part of the Oracle Database documentation set. You may also install
the schemas by following the instructions found in the Installing
the Sample Schemas and Establishing a Database Connection OBE.
Create Workspace, Projects
and ADF Business Services
When you work in JDeveloper, you organize your work in projects
within application workspaces. JDeveloper provides a number of predefined templates
which allow you to create a workspace and projects that are configured for developing
the types of application you are working on. The templates provide the basic
range of technologies that are needed, and you create your working environment
by selecting the one that fits your needs, then configuring it to add any additional
technologies you are going to use. The options that are available to you in
the New Gallery and for some context menu operations depend on your choice of
template for that workspace.
In this tutorial, you are going to choose the basic workspace
and project creation with no predefined technology.
In the application navigator, right-click Applications
and choose New Application Workspace from the context
menu.
2.
In the Create Application Workspace dialog,
rename the workspace Application
to LOVApplication.
.(Notice that the directory name changes to match the new name.)
Change the Application Template to Web Application [default],
and click OK.
3.
On completion, you should have an application named LovApplication
and two projects named Model and ViewController.
4.
From the File menu, choose Save All or click the
icon.
This section is going to cover how to create the business
services layer using ADF business components.
1.
Select the Model node in
the application navigator, and right-click to choose New
to display the New Gallery.
2.
In the New Gallery, open the Business Tier
node, select the Business Components category and double-click
the Business Components from Tables item.
3.
In the Business Components Project Initialization dialog,
select the connection that you created for the human resources (hr) schema,
for example, hr_conn, and click OK.
4.
The Create Business Components from Tables wizard appears.
Click Next on the Welcome page to begin.
5.
In Step 1 of 4: Entity Objects page, choose the HR schema
from the dropdown menu of available database schema objects, then select
the object type of Tables (if it is not already selected).
Select the DEPARTMENTS
and EMPLOYEES tables in
the Available list and click the Move button
to move those selections to the Selected list.
Click Next to continue.
6.
In Step 2 of 4: Updateable View Objects page, click the
Move All button
to move Departments and
Employees views to the
Selected list.
Click Next to continue.
7.
Click Next on the Read Only View Objects
From Tables page, and in the Application Module page, make no changes
and click Next.
8.
Click Finish to create the business components
in the Model project
9.
Your project should look like this:
10.
From the File menu, choose Save All or click the
icon.
In these steps you will create a
UIX page to access the business components. The procedure shows how to create
a form that displays data from Employees views using the Data Control Palette.
We would like to add an LOV to the EmpWithLOV.uix page,
for the Departments field. This field will be used to enter and change the department
for a particular employee.
In the EmpWithLOV editor, select the DepartmentId
row.
.
Remove the current DepartmentID field in the page.
2.
Select the DepartmentId attribute
in the DataControl palette underneath the EmployeesView1 node and set
the "Drag and Drop As:" type to: MessageLovInput
3.
Drag and drop the DepartmentId node onto
the page. Your page should look like this:
4.
From the File menu, choose Save All or click the
icon.
When you used the Data Control palette to create your new
MessageLovInput field, JDeveloper created a new UIX page called lovWindow0.uix,
that is pre-wired to your MessageLovInput field. The only thing that you have
to do is to add the data source for the LOV window.
1.
Open the application navigator and double-click the lovWindow0.uix
node.
The LovWindow0.uix page displays in the editor.
2.
In the Data Control palette select the DepartmentId
attribute underneath the DepartmentsView1 node.
3.
In the "Drag and Drop As"list,
choose "LOV Table", then Drag and drop the
DepartmentId node on the page.
4.
When you drop the DepartmentId attribute on your page,
you will be prompted with the Select pageflow Data Binding Option dialog.
Keep the default value; this will add a new node in your Struts page flow
that will represent your lovWindow0.uix page.
5.
Your page should look like this:
6.
From the File menu, choose Save All or click the
icon.
As you will have noticed, the LOV window contains
a Search field. This Search field is not wired up by default and in this session
we will add some components in order to make this work.
In the listOfValues components, there are several named
children (slots) that can be used, and one of them is particularly designed
to hold a dropdown list - filterChoice. In ADF UIX terminology, we call dropdown
lists "choice" components.
Now you need to modify the event handler to
make the filtering option work.
1.
In the structure pane, open the handlers
node and select the event - lovFilter..
2.
Right-click and select "Insert
inside ..." Select the invoke element
3.
In the dialog that appears, enter "setWhereClause"
for the Method property.
Note: This will call the setWhereClause method on the ViewObject
4.
Select the Enter Advanced Properties
tab, and set the following properties:
instance
${bindings.DepartmentId.viewObject}
java type
oracle.jbo.ViewObject
Then click OK.
5 .
Inside the new invoke element, add a Parameter element by right-clicking
the invoke node in the structure pane and select "Insert
Inside ..."
6.
Right-click the new parameter entry in the structure pane,
and select the parameter option.
7.
In the Insert parameter dialog, set javaType to string.
8.
Click the Enter Advanced Properties tab
and set the value field to ${empty param.filterBy ? 'DEPARTMENT_ID'
: param.filterBy} LIKE '${param.searchText}'
Then click OK.
9.
Right-click the event - lovFilter node
in the structure pane and add another invoke element.
10.
In the Insert Invoke dialog, set the method field to executeQuery
11.
Click the Enter Advanced Properties tab
and set the following properties:
instance
${bindings.DepartmentId.viewObject}
javaType
oracle.jbo.ViewObject
Click OK.
12.
Your event handler tree in the Structure pane should look
like this:
13.
In the structure pane, select the listOfValues
- DepartmentId node.
14.
In the property inspector, set the following properties:
Text property
${param.searchText}
searchAreaMode
filter
15.
Open the pageflow diagram.
16.
Right-click the /EmpWithLOV data page
and choose Run from the context menu.
17.
The EmpWithLOV opens in your browser.
Click the flash light to open the Department LOV.
18.
In the Search By, specify a new Department-Id value then
Go.
Experiment with the Search By Department Name and specify
a department value (Administration, Marketing, Purchasing and valid values)