Oracle ADF Code Corner: How-to build model driven List-of-Values in ADF Swing

How-to build model driven List-of-Values in ADF Swing

ADF Swing provides the option to build a text field with an associated list of values based on a View Object attribute. ADF Business Components is the business service used the most with ADF Swing. This makes the new model driven list of value available for the majority of ADF Swing developers. This how-to document explains the development of model driven list of values for ADF Swing by example of a pair of dependent LOV.

Written by Frank Nimphius, Oracle Corporation
30-Oct-2008

Introduction

In JDeveloper 10.1.3, the sole option to create a list of value is a manual configuration that associated the list VO with the source attribute that consumes the returned value. In JDeveloper 11, a new features of the business component framework allows developers to define the list of values within the View Object for a more consistent implementation with less overhead in the bindings. In this how-to we show how to configure model based list of values in ADF Swing so that two list of values operate in dependency to each other. Selecting a department in the first list will limit the list of employees returned from the second LOV

Defining the model driven LOV

The VacationrequestView object contains a foreign key to the Employees and Department table, represented by the EmployeesView and DepartmentsView objects.To create a list of value for the Departmentid,, select the Departmentid attribute and click the plus icon in the List of Values header.

In the List of Values dialog, click the plus icon next to the List Data Source field.

From the list of View Objects, choose the DepartmentsView view object.

From the List Attribute selection choose the DepartmentId attribute as the value attribute that is returned to the input field.

Map the DepartmentId attribute to the value of the target View Object (Departmentid). Press the UI Hints tab to configure the selection list as Input Text with List of Values and the attributes that should be shown in the LOV dialog.

With this configuration, the Departmentid attribute renders as a list of value when added to an ADF Swing panel. The next steps are to configure a dependent list of value field for the EmploeeId in the VacationRequest view object. Open the EmployeesView view object and select the Query tab. Click the plus icon in the ViewCriteria header. The view criteria is a named where clause that later restricts the employees query based on the Departmentid value

Define the view criteria so that the DepartmentId attribute of the Employee is mapped to the :deptId bind variable that you created pressing the New button next to the Parameter field. The type of the bind variable is of type Number.

Open the VacationrequestView object and select the Employeeid attribute to define the dependent list of value. Press the plus icon in the List of Values field.

In the LOV dialog, press the plus icon to choose the view object that represents the list of values.

Choose the EmployeesView object and shuffle it to the right side. Press the Edit button to launch the view criteria dialog.

Select the EmployeesViewCriteria and set the deliverable to Departmentid (note the lower id in the name). This copied the value of the selected row's Departmentid attribute into the bind variable.

After setting the view criteria, set the Default List Type list to Input Text with List of Values and choose the attributes to display in the LOV dialog.

Creating the ADF Swing Form

To create the ADF Swing form, drag and drop the VacationRequestsView collection onto the Swing panel.

In the opened context menu, choose Add Edit Form. The edit form will be created on a separate panel that is embedded in the current panel.

The configuration dialog of the edit form allows developers to choose the UI controls to be used to display the View Object attributes. The Departmentid and Employeeid attributes are pre defined as TextField with LOV, as configured on the View Object. Use the File Name field to give the embedded panel a better name than the suggested default.

As you can see from the image below, the to list of value fields are missing the label. You change this by opening the new panel, PanelVacationForm in the example. Switch to the visual editor and select the label area for the Departmentid on the left hand side of the list of value field. Open the Property Inspector (ctrl+shift+I) and set the Text property of the label.

Running the sample and pressing the list of value button next to the Department field, shows a list of departments.

Selecting a departments and then pressing the list of value button on the Employee field shows the dependent list of employees that work within the selected department

 


Download Sample Workspace

You can download the sample workspace from here. Before running the sample, install the SQL script and modify the database connection. As an exercise, re-build the sample and us dependent drop down lists instead of list of values.

 

 

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy