Every application requires the use of LOV (List of values) for selection and data entry. ADF provides a highly declarative way to construct LOV in the ADF-BC layer.
However there remains a challenge to store and maintain lookup codes. It is seldom a good practice to store different lookups in different tables.
Below I have tried to create a sample application that could be used as a guideline for creating lookup maintenance and usage apps.
It has the following features:
Search Lookups, Create/Edit Types and Codes (obviously).
Ability to (optionally) set translated display values.
Ability to define parent-child relationships between codes. eg country & state.
Ability to (optionally) define & use additional attributes to lookups. eg. country could have attribute 'area'.
Ability to define some lookups as 'reserved' against modifications.
The application can be downloaded from here
I have used JDeveloper 11gR1PS1 but of course ADF 10g and up can be used in similar fashion.
Create the tables using the table_create.sql file in model.lookup.common.diagram package.
Also insert lookup types for Language, YesNo and Validation Method. These are used for creating lookups.
The package model.lookup.common in the Model project contains the EO, VO and AM for maintenance of types, codes, translations and attributes.
To test the maintenance screens run the CodeSearch page in adfc-config.xml. In reality these 3 pages should be in a separate task flow.
There are different ways to use the lookups created:
1. Create different VOs for different lookup types. This approach of course has a disadvantage of repeating the same query in different VO. It is however useful in some cases where a unique way of querying is needed.
eg YesNoCheckboxVO. It is created as separate VO since we needed value 'Y' before 'N' (without bothering about translations). Hence its query contains a order by clause.
2. Create a common VO with parameters for Type, LangCode and optionally ParentCode. eg. LookupCodesRVO. Then while using, set the parameters in AM instance.
3. Create a common VO and then create View Criteria for each lookup type. This way while using, developers dont need to remember the lookup type and they can simply choose the lookup criteria they want. However the disadvantage is every new lookup we create, we need to add a view criteria too.
The page Home.jspx contains a couple of more examples that show how to use parent child lookups are used.
Please note that this application is not 100% bug free. Plus there are many other enhancements possible. Do leave a note if you find bugs.