Wednesday, June 14, 2017

Nice Trick to Get ADF LOV Description Text

I will tell you about nice trick to display LOV description. Usually you would create separate attribute in VO for LOV description and base LOV on this attribute (read about it in my previous post - Defining the LOV on a Reference Attribute in Oracle ADF 11g). But there is one more way - it makes it much faster to define LOV on description, but you should be aware about additional SQL statement executed to fetch description text.

You could set converter for ADF UI LOV, and then LOV component would use description by itself, without any additional configuration.

It is important to set correct order for LOV display attributes. Make sure to set description attribute to be first in the list for converter approach to work:


Go to ADF UI LOV component and set converter property. This must point to binding object, converter expression:


What you get - LOV field displays description, converter is able to mask ID value behind it:


It offers nice usability option - you could start typing description, press tab and value will be auto completed (if autoSubmit is set to true):


Behind the scenes it executes LOV SQL to get description text (this SQL is executed on page load too, which is not ideal when you have many LOV fields - in such situation is better to use separate attribute for description in the same VO):


When LOV value is changed and changes are saved, ADF BC updates ID value only (as expected):


Download sample application - ADFLovDescriptionApp.zip.

4 comments:

Anonymous said...

Nice post, Andrejus

I think , it faster than using combobox when page loading. Right?

nitesh said...

Hi Andrejus,

This works only if (JobId)Attribute type is String, I have tried on DeprartmentId, It isn't showing description. Do you have any solution for this?

Thanks
Nitesh


Andrejus Baranovskis said...

You should remove standard number converter added to LOV UI component, it will work then (tested).

Regards,
Andrejus

nitesh said...

Great :) Thanks for quick reply.