Wednesday, September 30, 2009

Persisting Query Criteria Results Across Sessions with Oracle MDS

For my previous blog post I got interesting comment from one of my readers - Husain. He was asking, how he can save search results across multiple sessions in Oracle ADF application. Actually, while asking he found solution by himself and updated my sample application from my previous post. Today I'll describe this updated application and will cover MDS topic for persisting query criteria results.

Download sample application - UserCustomizationsSession2.zip. As I already have mentioned, this sample is based on my previous sample application from User Customizations for Duration of Session in Oracle ADF 11g blog post. Main update in today sample is changed User Customization level from Duration of Session to Across Sessions with MDS:


When you want to use persistence across sessions feature for saving query criteria results, in order to make it work you need to enable ADF Security in your application:


And define some configuration settings in adf-config.xml file - setup persistence store and define customization class:


That's it, now we can test it. I have defined to users for my sample - john and scott, both have same role assigned and same password - welcome1. First we'll open sample application as john user:


Will perform query and store query parameter together with search results as FirstNameStartsWithS:


Search results are saved, user can navigate away from page and come back, he will have choice to retrieve saved results by selecting previously saved query from Saved Search list:


Now we should do a test - let's close Web browser and open application again. We will check if we will have our saved search remaining in a new session. We should login with the same user as before:


And..., it works - in Saved Search list we can see previously saved query parameter and search results - FirstNameStartsWithS:


If we choose FirstNameStartsWithS saved search, it brings correct results:


Its important to say, persisted changes are saved even WebLogic server goes down, its because user modifications are stored on file system in persistence store directory.

Now we should test with second user - scott, this user should not see saved search results by user john:


It works as expected, there are no saved search results for user scott:


Persistence store is created in WebLogic domain folder structure, you can see separate directories for Model and ViewController:


Difference in View Object for user john, is persisted and we can see saved query parameter with value assigned:

2 comments:

HusainD said...

Another Interesting Observation..
Say after personalizing the above search page, if we decide to change the view criteria to show more search-able fields, the user who has personalized will still see only one field.
Deleting the file EmployeesView.xml.xml from [JDEV_HOME]\system11.1.1.1.33.54.07\o.mds.dt\adrs\UserCustomizationsSession\AutoGeneratedMar\mds_adrs_writedir\persdef\lt\andrejusb\model\views\mdssys\cust\user\[your user]
Could fix the problem but it also deletes any of his personalizations.

Andrejus Baranovskis said...

Users will personalize search in production application. While in production, usually we are not changing View Criteria definition in View Object. So its ok.

Andrejus