Tuesday, September 17, 2013

ADF Query Saved Search in ADF 12c

ADF Query Saved Search functionality exists starting from ADF 11g - Persisting Query Criteria Results Across Sessions with Oracle MDS. Same works in ADF 12c, and more - from UI point behaviour improved. There are nicer and cleaner dialogs prompting user to save search after changes were applied. You need to remember few tricks to enable Saved Search functionality, I will list all of them in this post.

Firstly goes quite obvious step - enable user customizations across sessions using MDS in ADF View configuration. With this setting, SavedSearchApp.zip application is enabled to store user personalizations into MDS repository (it can be file system or DB):

It is important to enable ADF Security, as user personalizations must be stored for every user under user name context. MDS engine retrieves user name from ADF Security automatically. Screen to enable ADF Security:

One of the last bits - open adf-config.xml and in MDS section specify UserCC class from ADF library:

Specifically for ADF Query Saved Search functionality, make sure to add persistence config into MDS configuration section:

I noticed, when running MDS enabled application for the first time in 12c environment, it may fail with error: metadata store mapped to the namespace / BASE DEFAULT is read only. This can be fixed by adding MDS store class into config. For example, if you are using file store, define FileMetadataStore class as per this example:

Different class should be used in case when MDS repository is created in DB: oracle.mds.persistence.stores.db.DBMetadataStore.

Here how it looks on runtime. Let's assume you go to Advanced mode and add new query field (Email in this example). On the next action, ADF Query is going to ask you one time, if this change needs to be saved:

If you decide to save ADF Query changes, there is nice dialog to provide customization name, set it to be activated by default and executed automatically without pressing Search button again:

Saved search personalization is available in the list and can be selected any time:

Personalization is saved and available after logout/login - it renders added field and remembers entered criteria value:

Saved search personalization can be easily removed through ADF Query dialog:

This functionality is very important for the users, as it allows to perform search faster without entering parameters again and again. It improves application performance, as search is executed with parameters from the start, limiting results list.


Aurimas Lacitis said...

Hello Andrejus,
Good post !
Is this functionality available for ADF Essentials ?

Andrejus Baranovskis said...


I was testing same functionality on Glassfish, it doesnt seem to work, is not able to write MDS customizations on disk. May be there is some workaround, I will need to investigate. It doesn't work in simple way, just as it works on WLS.


동올애비 said...

Although I do not know it is feasible with ADF Essentials technically, the following url said that MDS is not included in ADF Essentials http://www.oracle.com/technetwork/developer-tools/adf/overview/adfessentialsfaq-1837249.pdf

Lukasz Romaszewski said...


from my understanding MDS is not supported in ADF Essentials so it will not work.

Andrejus Baranovskis said...

Thanks for update - officially yes, not included. However, technically it should work - as MDS API functionality and classes are recognized. The only problem - it doesn't write to MDS repository, I will continue to research it and may be will find out one or another hack.


ashu said...

Hi Andrejus,
Thanks for the post.
I have encountered a problem related to this af:query component, need your help.
I have an search table (af:table) attached to af:query component.

1. After performing any search I am saving that search (by unchecking the run automatically option).
2. Now using personalize option I am deleting the search.
3. Now without clicking on search I am trying to open an item previously present in search table, getting null pointer exception.
Can you please suggest me what may be the possible cause of exception.
I mean I should perform search first but previously presented item should not return a null.

Georgi said...

Hi Andrejus,

Great post as always. I need to find the skin selector id of the new message for warning to save the changed search. I need to translate into my language and use in my skin, as ADF does not support BG. I looked at http://docs.oracle.com/middleware/1212/adf/TROSS/toc.htm but it is not listed. Do you know how to go about finding the id of the dialog title "Warning", and the message inside the dialog?

Georgi said...

I have one more question. As soon as I enable user customizations in project properties, the visual editor of pages or fragments is broken. Have you experienced this, any tips? I am on Windows 7 and 64bit JDev. Thanks in advance.

Ravichandra Sreenivas said...

Hi Andrejus,
Is it possible to exclude few search items from being saved along with saved searches. I mean for example, I have 5 items in search panel and want to save only 4 when user selects to save this current search. Can we do this ? How can we achieve this .. is there any parameter that can handle this in ADF view criteria or elsewhere.

Susanto Paul said...

Hi Andrejus,
This post is excellent and very helpful. Now, I have a requirement which is just an enhancement of your post. Suppose I added one more field in the af:query. Ideally it is displayed along with the delete icon. After that I Save the state. But now the delete icon is not available after click of Save button. I want the delete icon to be still there after I have clicked Saved button. In other words, want to Update a user-created saved search.

Thanks & Regards,
Susanto Paul