In a Struts / JSP application JDeveloper 10g provides a simple way
of creating bound input forms allowing you to drag the basic form from the relevant
collection in the data control palette. Furthermore you can render individual
input fields in a variety of ways, in this case we'll look at creating a databound
pop-list (drop down list) step by step.
In this example we'll be using a screen created with a basic input form based
on the Employees table from the Oracle standard HR demo schema. The model project
for this example uses ADF Business Components to expose record collections for
the Employees (the basis of the form), and a second record collection containing
all Departments which will be used to populate the pop-list.
So in this tip we'll go through the steps required to replace the circled Department
ID number field with a bound pop list that contains the names of all the Departments.
Steps to Create the Databound Pop List
Delete the existing field (This can just be done in the JSP visual editor).
Open the Data Control palette, expand the EmployeesView collection
and select the DepartmentId attribute. In the Drag
and Drop As poplist at the bottom of the Data Control Palette select
the control type Single Select List.
Drag the selected DepartmentId attribute
from the palette into the space vacated by the DepartmentID field that you
have just deleted. You should see it dropped as a pop-list widget.
Now click on the UI Model Tab ( )
of the Structure Pane on the page you will see the following structure:
Notice the DepartmentId1 attribute at the bottom of this list - this is
the binding for new list item that you just created.
Double click (or choose Edit from the context menu) on this new binding.
The List Binding Editor will appear:
Use the List Binding Mode: poplist at
the top of the dialog to change the mode to LOV Mode:
This dialog has a Source Data Collection which will be a record collection
(e.g. a Business Components View Object) which will provide the valid list
of values. The Target Data Collection is preselected and represents
the data collection that the input form is based on.
So the next task is to create a source iterator on the source collection
for the list. Expand the data control and select the correct collection. In
this case there is a View Object DepartmentsListView
already set up:
Press the New button to create a new LOV
Source iterator, accept the default name:
Set the Select LOV Source Iterator poplist
to this new iterator (DepartmentsListViewIterator), the Add button on the
dialog will then enable. Press the Add button and set the join attributes
(i.e. DepartmentId = DepartmentId). Your dialog should now look like
this:
The final step is to define what data the pop-list should display, click
the LOV Display Attributes tab on the dialog
and shuttle the DepartmentName field into
the Attributes to Display list:
The setup of the pop-list is now all complete, and when run, the Data Page
will look like this:
Conclusion
The ADF Model data binding mechanism provides a powerful and
convenient mechanism for creating data bound lists of values. This how-to has
described the creation of drop down lists, but the same principles can be applied
to create multi-select lists and radio groups.