Friday, July 19, 2013

ADF 12c: Model-Driven LOV with Bean Data Control


Prior to ADF 12c Model-driven input List-Of-Values (LOV) was a feature exclusively reserved to the ADF BC DataControl. With ADF 12c the Bean DataControl has been enhanced a lot. Now it is possible to create input LOVs the declarative way.

You have a plain Java Object Model, for which you want to build the UI, including an LOV. In this sample we use Person, Address and a PersonService, which we want to expose as a DataControl
The adressId of Person should be filled through a LOV from available Address-Entities.

How to do it

First, create the DataControl from the PersonService: Right Click the class and Choose: Create DataControl

For this purpose, just keep the defaults in the wizard and complete with "Finish"

Open the generated DataControls.dcx, Select the Collection Type person and choose 'Edit'

The metadata file for the Person entity will be created. Next open the generated metadata file and configure the LOV on addressId as follows

Now the LOV is already configured and could be used for the UI Creation. If needed the LOV can be refined with UI Hints (as known from the ADF BC LOVs)

Now you can go on an build the UI. Drop the persons collection from the Data Control Palette onto the Page and
choose "ADF Form":

As indicated an ADF LOV Input will be crated for the addressId attribute. It can be further adjusted if needed in the next wizard screen

The LOV has been created

and can be tested at runtime.

The LOV Popup contains a query panel to limit the given values. As a wildcard only % is working. no Asterisk (*) what I personally would prefer. Anyway the LOV works as expected. In the sample the adressId is filled correctly.

Validation also works by default. If you try to enter an invalid value an error message pops up.


Further Reading