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:

13 comments:

  1. 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.

    ReplyDelete
  2. 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

    ReplyDelete
  3. It works great for saving the search results.Thanks,but it fails to persist the results layout.

    Steps to reproduce:
    1) Enter a search criteria and click on search
    2) Move a column on the results table from one position to another
    3) Select the Save Results Layout checkbox while saving the search results.

    Regards
    Sudhakar

    ReplyDelete
  4. Seems like you are mixing things a bit. ADF Query Save Search stores search parameters only.

    If you want to store table columns re-arrangement, enable MDS session option.

    Andrejus

    ReplyDelete
  5. Hi Andrejus,
    Thanks for the quick reply !!!

    ADF Query Save Search stores search parameters only.

    The above statement is little confusing for me as when I click on the save it opens a popup titled
    "Create Saved Search" with following options

    1) Set as Default
    2) Run Automatically
    3) Save Results Layout

    If I enable MDS session option then it only persists for the current session.Our user community would like to save a search with the layout change and use it in future sessions.

    Regards
    Sudhakar

    ReplyDelete
  6. I mean - across sessions using MDS.

    Andrejus

    ReplyDelete
  7. Hi Andrejus. Do you know of a way to publish a saved search so that users can share their searches? That way user "Bob" could see "Sallies" query results.

    I know this is not out of the box functinality. I'm just wondering if there is a way to query this information or evolve the mds interactions so that we can get a "complete" list which includes other users saved search criteria.

    I'm trying to avoid writing my own component to do this.

    Thanks,


    BradW

    ReplyDelete
  8. Hi Andrejus.

    I'm just wondering whether you know of a way to customized the save functionality? Basically, we want to be able to add an attribute as to whether the query is shareable and then allow the list to show all my lists plus all shareable search results.

    I'm trying to avoid writing my own custom components.

    Thanks,


    BradW

    ReplyDelete
  9. I'm afraid it will be quite complex to do it out of the box.

    Andrejus

    ReplyDelete
  10. Hi Andrejus,

    we have written a custom search. Can we save the custom search. If so how can we save the cusotm search. One more step is that can we use MDS in the custom search.
    Please suggest. Thank you.

    ReplyDelete
  11. Hi,

    I doubt if you can use MDS for custom search save. Unless you override MDS classes, you may want to double check this doc: http://community.oraclepressbooks.com/downloads/S316901-customization.pdf

    Andrejus

    ReplyDelete
  12. Hi Andrejus,
    When i am trying to Update the Saved Search Null Pointer Exceptions are thrown
    Steps to reproduce
    1.Enter Search Criteria and Click on Save
    2.Search Saved successfully
    3.Modify Search Criteria and click on Save which gives Null Pointer Exception

    ReplyDelete
  13. By coincidence I was testing the same today and it worked fine with ADF 11.1.1.7

    Regards,
    Andrejus

    ReplyDelete