Clear search criteria on lov start-up in JHeadstart 10.1.3


A list of values (LOV) is an ADF Faces component that allows the user to select an item from a popup window with a list of items and load the value(s) into the specified field(s). Oracle JHeadstart automatically generates several search features for LOV type fields. It generates the simple and advanced search functionalities, in addition of validating text entered against the list, showing the records that meet the filter or, if there is just one match, loading the values in the fields. The criteria and results of the latest executed search are maintained during the session. This behavior is the same for any search executed on any ViewObject usage.


It can be required for LOV type fields not to save criteria and results from the previous search but instead show the complete list to choose in the lookup. To achieve this behavior it is necessary to clear the search criteria and re-execute the query with no filter values. This represents a performance penalty by having to execute an extra query each time a LOV is opened. The positive side is that it is only necessary to execute this extra query when the previous one was executed with not null criteria values.


The steps to implement this solution in JHeadstart 10.1.3 are described below:


  1. Extend the oracle.jheadstart.controller.jsf.bean.LovItemBean class.
  2. Overwrite the setLovSearchBean method, which is invoked several times during the use of a LOV:

    • Loading a page that contains any LOV type field.
    • Opening the window associated to a list of values.
    • Validating a string against a LOV.
    • Selecting a value from a LOV
    • Closing the window associated to a list of values.



    This method receives an object of type oracle.jheadstart.controller.jsf.bean.JhsSearchBean that contains the objects where the search criteria are kept:

    • SearchText and Criteria when Quick Search is executed.
    • Criteria when Advanced Search is executed.



    To ensure that a full query is executed if the previous search was more restricted, change the overridden method as shown below:

    public void setLovSearchBean (JhsSearchBean lovSearchBean){
    JhsSearchBean lsb = lovSearchBean;
    if(lsb!=null && (lsb.getSearchText()!=null || lsb.getCriteria().size()>0)) {
    lsb.setSearchText(null);
    lsb.getCriteria().clear();
    lsb.quickSearch();
    }
    super.setLovSearchBean(lovSearchBean);
    }

    Only when SearchText object is not null or Criteria object is not empty, the search criteria is cleared (lsb.setSearchText(null) lsb.getCriteria().clear()) and the search with no filter values is re-executed (lsb.quickSearch()).
  3. Create a new version of the velocity template misc/facesconfig/lovItemBean.vm which will reference the new class created in the first step:

    <managed-bean>
    <managed-bean-name>${bean.beanName}</managed-bean-name>
    <managed-bean-class>new LovItemBean class created</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>

    </managed-bean>

    See section 4.7 of the JHeadstart Developer's Guide for more information about customizing generator templates.
  4. Associate this new template to the LOVs requested to have this behavior.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Java EE Consultants - JHeadstart, ADF, JSF

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today