Developer Tools
JDeveloper
Written by Duncan Mills, Oracle Corporation
April 2004
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 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 drop down list that contains the names of all the Departments and populates the underlying attribute in the employees table.
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 selection list 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: list 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 pre selected and represents the data collection that the input form is based on.
List bindings provide a essential tool in building effective user interfaces, and are simple to implement in a declarative manner. Although the example shown here has been concerned with creating a list binding for drop down lists, the same method is used to create bindings for other list selection User interfaces such as T-Lists, radio groups, and check box groups. For a larger range of examples see the DataBound Lists using ADF sample on OTN ( http://otn.oracle.com/sample_code/products/jdev/index.html), which provides a workspace containing several different list binding implementations.
The basic technique shown for creating a list binding is also applicable for use with alternative user interface technologies in ADF such as ADF UIX or ADF JClient. In both cases the user interface elements bound to the list bindings will be different, but the creation of the actual binding is identical.