07-Manual Search in Oracle OAF

 Make sure you have setup your jDeveloper properly and created OAWorkspace. In case you have not done that before, click here to see how.

Click here to know different types of search pages in OAF.

Below are the steps in brief:

  • Create Application Module (AM)
  • Create View Object (VO)
  • Add VO to AM
  • Create a page
  • Add search fields to the page layout 
  • Add Table Region to the page
  • Add function in Application Module Java file (Impl) to set the where clause dynamically
  • Invoke the Application Module function from controller file

We will add new package (manualsearch as subcomponent of component demo) in our previous application workspace. For detailed tutorial on adding all the business components view the previous post here. 


  • Add the ManualSearchAM 




  • Add the ManualSearchVO using the below query

SELECT
    ooha.header_id,
    ooha.order_number,
    ooha.cust_po_number,
    ooha.ordered_date,
    ooha.org_id,
    hou.name org_name
FROM
    oe_order_headers_all  ooha,
    hr_operating_units    hou
WHERE
    ooha.org_id = hou.organization_id







  • Add ManualSearchVO to ManualSearchAM




  • Add ManualSearchPG

  • Set below properties of Page Layout Region of the page

  • Add new region inside PageLayoutRN and change the style to messageComponentLayout

  • Inside SearchRN add two messageTextInput fields OrderNumberTxt and OrgNameTxt . Also add the prompt for these fields.

  • Add messageLayout inside SearchRN and two submitButton items




  • Right click SearchRN and select New -> Region Using Wizard


  • Set the Region Id as ResultTable and Region Style as table

  • Select all the attributes


  • Select the ManualSearchAM and then select ManualSearchVO


  • Select Style of each attribute as messageStyledText






  • Right click SearchRN and select Set New Controller and add the controller file


  • Write the below code in the controller file's processFormRequest method
package oracle.apps.cie.demo.manualsearch.webui;

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class ManualSearchCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    
    OAApplicationModule am=(OAApplicationModule)pageContext.getApplicationModule(webBean);
    
    //Below code will be executed when GoBtn is clicked
    if(pageContext.getParameter("GoBtn")!=null){
        String orderNumber=pageContext.getParameter("OrderNumberTxt");
        String orgName=pageContext.getParameter("OrgNameTxt");
        
        //Serialize the parameters to send to Application Module Impl file
        Serializable params[]={orderNumber,orgName};
        
        //Call the Application Module Impl file's function
        am.invokeMethod("filterOrder",params);
    }

  }

}



  • Click the ManualSearchAM in the structure window and open the file ManualSearchAMImpl.java. This is the implementation file of the application module.

  • Add the below code in ManualSearchAMImpl.java file
package oracle.apps.cie.demo.manualsearch.server;

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class ManualSearchAMImpl extends OAApplicationModuleImpl {
    /**This is the default constructor (do not remove)
     */
    public ManualSearchAMImpl() {
    }

    /**Sample main for debugging Business Components code using the tester.
     */
    public static void main(String[] args) {
        launchTester("oracle.apps.cie.demo.manualsearch.server"/* package name */
      "ManualSearchAMLocal" /* Configuration Name */);
    }

    /**Container's getter for ManualSearchVO
     */
    public ManualSearchVOImpl getManualSearchVO() {
        return (ManualSearchVOImpl)findViewObject("ManualSearchVO");
    }
    
    public void filterOrder(String orderNumber,String orgName){
        //Get Handle of the view object
        ManualSearchVOImpl manualSearchVo=getManualSearchVO();
        
        //Set where clause to the view object
        manualSearchVo.setWhereClause("order_number = nvl(:1,order_number) and org_name = nvl(:2,org_name) ");
        
        //Set the where clause parameters 
        manualSearchVo.setWhereClauseParam(0,orderNumber);
        manualSearchVo.setWhereClauseParam(1,orgName);
        
        //Execute this where clause now
        manualSearchVo.executeQuery();
    } 
}



In case you don't want to write the code in the Application Module Impl file, use the below code to perform same operation via Controller File only

/*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package oracle.apps.cie.demo.manualsearch.webui;

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class ManualSearchCO extends OAControllerImpl {
    public static final String RCS_ID = "$Header$";
    public static final boolean RCS_ID_RECORDED = 
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

    /**
     * Layout and page setup logic for a region.
     * @param pageContext the current OA page context
     * @param webBean the web bean corresponding to the region
     */
    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);
    }

    /**
     * Procedure to handle form submissions for form elements in
     * a region.
     * @param pageContext the current OA page context
     * @param webBean the web bean corresponding to the region
     */
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processFormRequest(pageContext, webBean);
        OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);

        //Below code will be executed when GoBtn is clicked
        if (pageContext.getParameter("GoBtn") != null) {
            String orderNumber = pageContext.getParameter("OrderNumberTxt");
            String orgName = pageContext.getParameter("OrgNameTxt");

            OAViewObject manualSearchVo = (OAViewObject)am.findViewObject("ManualSearchVO");

            //Set where clause to the view object
            manualSearchVo.setWhereClause("order_number = nvl(:1,order_number) and org_name = nvl(:2,org_name) ");

            //Set the where clause parameters 
            manualSearchVo.setWhereClauseParam(0, orderNumber);
            manualSearchVo.setWhereClauseParam(1, orgName);

            //Execute this where clause now
            manualSearchVo.executeQuery();

        }
    }

}

  • Use the below code for Clear Button in processFormRequest method of the controller file
    //Below code will be executed when CancelBtn is clicked
    if (pageContext.getParameter("CancelBtn") != null) {
        OAMessageTextInputBean orderNumberTxt=(OAMessageTextInputBean)webBean.findChildRecursive("OrderNumberTxt");
        orderNumberTxt.setValue(pageContext,null);
        
        OAMessageTextInputBean orgNameTxt=(OAMessageTextInputBean)webBean.findChildRecursive("OrgNameTxt");
        orgNameTxt.setValue(pageContext,null);
    }
  • Save all the work and right click ManualSearchPG to run the page


Comments