There is one less known feature of ADF UI LOV component. There is a way to enable additional built-in button for ADF UI LOV popup, this button is rendered as create type icon. Custom popup can be attached to that button and then we can render pretty much anything from that custom popup. I will show you how this is done, based on Oracle ADF UI developer guide - Create Icon in Toolbar of Popup Dialog. This is useful when you want to allow users to maintain the list directly from ADF UI LOV popup.
Sample application - LOVNewRowApp.zip contains LOV component for JOB_ID:
There is ADF UI LOV component property - CreatePopupId. You should set ID of your custom popup you want to be loaded from ADF UI LOV, button with create icon will be rendered out of the box for you once this ID is set:
My custom popup implements listeners to be executed on fetch and on cancel, this is needed to prepare new row when popup loads and roll it back in case of cancelation:
Set dialog listener to perform transaction commit and insert new record:
Source code for these listeners is pretty simple, it calls methods from bindings:
Here you can see regular ADF UI LOV rendered with create icon just above the results table:
Hit this create button and referenced custom popup through ID will get displayed. Popup fetch listener creates new row before popup is loaded, so we can see blank row inserted:
Type data for the new job and press OK:
Custom popup will be closed and newly inserted record will appear in the LOV list instantly (you may need to press Search button in the LOV window):
Sample application - LOVNewRowApp.zip contains LOV component for JOB_ID:
There is ADF UI LOV component property - CreatePopupId. You should set ID of your custom popup you want to be loaded from ADF UI LOV, button with create icon will be rendered out of the box for you once this ID is set:
My custom popup implements listeners to be executed on fetch and on cancel, this is needed to prepare new row when popup loads and roll it back in case of cancelation:
Set dialog listener to perform transaction commit and insert new record:
Source code for these listeners is pretty simple, it calls methods from bindings:
Here you can see regular ADF UI LOV rendered with create icon just above the results table:
Hit this create button and referenced custom popup through ID will get displayed. Popup fetch listener creates new row before popup is loaded, so we can see blank row inserted:
Type data for the new job and press OK:
Custom popup will be closed and newly inserted record will appear in the LOV list instantly (you may need to press Search button in the LOV window):
Hi Andrejus,
ReplyDeleteYour posts are very helpful.
i have requirement to display job title instead of job id, After selecting the lov. While saving into DB it should save jobId. Is it possible ??
Thanks,
Nitesh
Thanks Nitesh. Yes you can, check this post: http://andrejusb.blogspot.com/2009/11/defining-lov-on-reference-attribute-in.html
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteI tried to create my own "LOVNewRowApp_myversion" application from scratch and use your created application as a guide and when I tried to add an LOV binding in mainPageDef.xml Overview tab, there is no selectable values in "Server List Binding Name" dropdown. In your application it's "LOV_JobId". How is it declared or created so that there will be a selectable value?
No need to add it manually in the page def. It gets auto generated - when you drag and drop LOV into the page.
ReplyDeleteAndrejus
Hello,
ReplyDeleteIs it possible to add more buttons to the LoV so that the user can not only add jobs, but also edit and delete them?
I think Create button is only one available out of the box, at the moment.
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteI was trying the same application.
After inserting new job in custom popup, it is not appearing in LOV list(new job has been inserted in database successfully).
I am using JDeveloper 11.1.1.5
Can you tell me where I'm doing a mistake?
Thanks,
Kapil
Kapil Yadav you should have to update the view object problematically after insert the record.
ReplyDelete