How To Create a Databound Pop-list with Oracle JDeveloper 10 g

An Oracle JDeveloper How To Document
Duncan Mills
Febuary 2004

Contents

      Introduction
      Steps to Create the Databound Pop List
      Conclusion

 

Introduction

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

  1. Delete the existing field (This can just be done in the JSP visual editor).

  2. 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.
    Selecting a list widget in the Data Control Palette

  3. 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.

  4. Now click on the UI Model Tab ( Image of the UI Model tab in the structure pane) of the Structure Pane on the page you will see the following structure:
    UI Model for databound page
    Notice the DepartmentId1 attribute at the bottom of this list - this is the binding for new list item that you just created.

  5. Double click (or choose Edit from the context menu) on this new binding. The List Binding Editor will appear:
    Initial view of the list binding screen
     

  6. Use the List Binding Mode: poplist at the top of the dialog to change the mode to LOV Mode:
    LIst Binding dialog LOV mode screen
    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.

  7. 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:
    Setting the source collection
  8. Press the New button to create a new LOV Source iterator, accept the default name:
    New Iterator creation dialog
  9. 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:
    List Binding screen with the mapping complete
  10. 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:
    Selecting the poplist display columns in the list bindings editor
  11. The setup of the pop-list is now all complete, and when run, the Data Page will look like this:
    Finished input form with pop list

 

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.

drmills v1.1 09-Feb-2004

false ,,,,,,,,,,,,,,,