A user on the OTN JDeveloper & ADF forum asked how to use one ViewObject, which holds lookup data of different areads, as LOV source. This post shows how to do this.
UPDATE:
In part 2 I added a use case which shows how to use a global lookup view object to initialize a LOV component before a page loads and show the selected lookup data.
Before we begin we have to setup the data for the the sample we build to work with. For this we add two tables to the HR schema (or any other schema you have access to). One, GENERALLOOKUP, hols lookup data, which is grouped ba a type attribute.
As we see the type column is used to group the data into different areas. The task is to use one view object which queries this table as base for model driven LOVs. To show this we need another table which we use to enter values selected by a LOV for the area from the type column.
Scripts to create the tables and insert some data into them are provided together with the sample workspace in the file ‘setup_db.sql’. After we setup the table and the data we create entity objects and view objects like we normally do. Once the eo and vo are created, we add a view criteria which we use to select a specific type of lookup data from the GENERALLOOKUP table.
The view criteria has one bind variable which we later use to distinguish the different groups of lookup data. Now we can setup the lov for the attributes of the LookupTestView view object. We show this for the TitleId attribute:
rename the view object to TiltelookupView andshuttle it to the selected area
Click the edit button on the top right
The vital part is that we switch to the ‘View Object’ node and select the view criteria ‘TypeLookupViewCriteria’ and set the bind variable to the desired type. In this case it is ‘TITLE’
Once the list source is setup we select the id of the list source (TitlelookupView) as ‘List Attribute’ and set the TitleId as ‘View Attribute’ for the id. Finally select the ‘UI Hint’ tab and shuttle the ‘Data’ attribute to the ‘Selected’ side. The ‘Data’ attribute of the TitlelookupView will then shown in the listbox on the UI.
This concludes the implementation for the TitleId attribute. The other attributes (GenderId, PositionId and WeekdayId) are done hte same way. Only change the bind variable ‘bindType’ to the type area you are generating the LOV for.
The gallery above shows the running application. You can download the sample workspace which was build JDeveloper 11.1.1.7.0 and using the HR schema from the ADF EMG Samples side BlogStaticVOLov_V2.zip. You can open the workspace using JDev 11.1.1.6.0 without a problem. If you are asked if you like to migrate the workspace to 11.1.1.6.0 answer with Yes.
UPDATE:
In part 2 I added a use case which shows how to use a global lookup view object to initialize a LOV component before a page loads and show the selected lookup data.
Hi,
Thanks for the post, Just wanted to know if any significant performance issues will be caused by this approach?
Thanks.
Hi, no performance issue I know of. As the data is EO based there will be a cache for the data.
If you see a problem provide a test case…
Timo
Thanks for the prompt reply,
Haven’t run into any problems yet, just wanted to be sure before we got started.
Hi Timo,
Thanks for pointing out this post. I implemented this approach but my doubt was in term of CACHE and using this viewObject in a sharedApplicationModule. Would this approach be the same, less or more effective than creating many viewObjects based on the same EO and overriding the query itself to just use the set of data that I really need. My lookup table comes from Oracle Apps and it has 200699 rows. So I thought that creating few viewObjects restricting to the rows I need would be more effective since they will be cached by the EO and query will be executed just once in the sharedAppModule, but I would like your input on this.
Regards
Alejandro Tovar Lanz
If you build many vo based on the same eo they share the same eo cache. There should no difference between the two approaches in this case. As long the the lookup table has the right index defined the retrieval of the rows should be no problem.
Thanks for your Great Blog, I started it from the beginning & Continue learning.
My Question is that; What are your suggestion to the suitable data that to be put in a shared Lookup? in other words, How can we say that this data is to be put as a shared lookup?
Best Regards!!!