Pages

Wednesday, July 9, 2008

Save your searches in an ADF Query panel

Probably your already know the ADF Search form in Jdeveloper 11G . You can get this choice when you drag a viewobject from the datacontrol to the page. This is nice but it can be lot cooler and better. In 11g you can use Query panels. This panel not only looks better but the user can personalize this panel and save its searches. So the next time the user can use them again. The query panel also give you more search options like greater than or between.

In this blog I will show you what you need to do to make this work. You need to know a litte bit about MDS and ADF security, for more info read my previous blog.
The ADF Query panel not only displays the attributes of the viewobject but also the viewobject criteria's. For this I created a new criteria called SalaryCriteria. To do this yourself we have to open the viewobject, go to the query part and there we see the defined criteria's.
In this editor you can create a complex where clause. The bind variables you use in this criteria are displayed as search attributes in the ADF Query Panel.


When you open the viewobject in the datacontrol there is a sub folder called Named Criteria. You can drag one of the criteria's to the page. If you use All Queriable Attributes then you get as default, a query panel with all the queriable attributes of the viewobject. When we use the SalaryCriteria then only the salary bind variable is displayed, off course you can still use the other attributes for a search operation.
When you drag a named criteria on the jsf page you get a chioce to select a particular query panel. I now use the ADF Query Panel with Table. With Table means with a search result table.

Here you see result when we drag the all queriable attributes named criteria from the datacontrol. Now if we want to save the search we have to use the ADF Security wizard and add security to the page definition of this search page. The last step is to configure MDS in this web application. We have to enable MDS on the viewcontroller project and pages and of course. configure adf-config.xml for MDS, you can use the adf-config of my previous blog, you only have to change the folders of the metadata path.


When we press save in the Query Panel we get a dialog where we can save the search

In the top right of the Query Panel you can select your own saved searches or the view criteria's




Here you see what is happening when you save a search. ADF creates a persdef folder and in this folder ADF makes a copy of the used viewobject and adds the new search criteria to it. ADF does the same thing as we did manually in the viewobject.

4 comments:

  1. Hi Edwin,

    Thanks for this post it helps a lot.
    I was trying this in 11gR1 and faced a road block.
    I did the following:
    enabled file based default security.
    enabled user customization across session for ViewController project
    created a simple view Criteria on Country_Codes table in HR schema
    created a page with search region for the viewCriteria.
    Finally added view permission to my role.

    However when I run the page, it throws an error:
    [JpsAuth] Check Permission
    PolicyContext: [UserCustomizationApp#V2.0]
    Resource/Target: [sessiondef.view_pageDefs_SearchCustomizationPageDef_CountryCodesViewCriteriaQuery_VCTree_Root_internal_vcival_def_961_DynamicRegion]
    Action: [view]
    Permission Class: [oracle.adf.share.security.authorization.RegionPermission]
    Result: [FAILED]
    For more information on this failure, please set -Djps.auth.debug.enable=true


    The page loads fine though but it does not save my search results. Every saved search criteria returns the default results.

    Any idea what I am missing?

    Thanks,
    Husain

    ReplyDelete
  2. Hi,

    did you see this post http://biemond.blogspot.com/2009/07/customize-and-personalize-your-jsf.html

    and this http://biemond.blogspot.com/2009/07/mds-repository-for-adf-11g.html

    this post is made with a old version
    thanks

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks Edwin,

    I followed your blogs.
    Unfortunately 11gR1 has a known bug for saved search persistence: http://www.oracle.com/technology/products/jdev/htdocs/11/11.1.1.1/knownissues.html#cust8

    I finally ended up modifying Andrejus's application
    http://andrejusb.blogspot.com/2009/09/user-customizations-for-duration-of.html
    and added Security, Code to adf-config.xml and Checked "Across sessions using MDS"
    Now it does work ok.

    Thanks,
    Husain

    ReplyDelete