Contact : oafqueries@gmail.com (OAF/ADF Trainings and Customizations)

Wednesday, October 20

How to capture the Go button for the Query region and edit the where cause

Hi,

On query region we can capture the Go button click and execute our own search along with Standard Search.

     OAApplicationModule ap = (OAApplicationModule)pageContext.getApplicationModule(webBean);
    OAQueryBean bean = (OAQueryBean)webBean.findIndexedChildRecursive("queryRN");
    if(bean!=null)
    {
      String id = (String)bean.getGoButtonName();
      if(pageContext.getParameter(id)!=null)
      {
          ap.invokeMethod("initsearch",params);
       }

public void initsearch(String fromnum,String tonum,String fromdate,String todate)
 { 
    String whereClause = null;
    int whereClausecount = 0;
    OAViewObject vo = (OAViewObject)getReprintInvoiceVO1();
    vo.setWhereClause(null);
    vo.setWhereClauseParams(null);
   if(fromnum!=null&&!("".equals(fromnum.trim())))
    {
      whereClause = "INVOICE_NUMBER >= :1" ;
      vo.setWhereClauseParam(whereClausecount,fromnum);
      whereClausecount++;
    }
    if(tonum!=null&&!("".equals(tonum.trim())))
    {
      
      if(whereClause!=null)
      {
       
        whereClause = whereClause +" AND INVOICE_NUMBER <= :2";
        vo.setWhereClauseParam(whereClausecount,tonum);
        whereClausecount++;
      }
      else
      {
       
        whereClause = "INVOICE_NUMBER <= :1";
        vo.setWhereClauseParam(whereClausecount,tonum);
        whereClausecount++;
      }   
    }
    if(fromdate!=null&&!("".equals(fromdate.trim())))
    {
     if(whereClause!=null)
     {
       if((fromnum!=null&&!("".equals(fromnum.trim())))&&(tonum!=null&&!("".equals(tonum.trim()))))
       {
         whereClause = whereClause +" AND INVOICE_DATE > = :3";
         vo.setWhereClauseParam(whereClausecount,fromdate);
         whereClausecount++; 
       }
       else
       {
         whereClause = whereClause +" AND INVOICE_DATE > = :2";
         vo.setWhereClauseParam(whereClausecount,fromdate);
         whereClausecount++;
       }
      
     }
     else
     {
        whereClause = " INVOICE_DATE >= :1";
        vo.setWhereClauseParam(whereClausecount,fromdate);
        whereClausecount++;
     }
    }
    if(todate!=null&&!("".equals(todate.trim())))
    {
     if(whereClause!=null)
     {
       if((fromnum!=null&&!("".equals(fromnum.trim())))&&(tonum!=null&&!("".equals(tonum.trim())))&&(fromdate!=null&&!("".equals(fromdate.trim()))))
       {
         whereClause = whereClause +" AND INVOICE_DATE < = :4";
         vo.setWhereClauseParam(whereClausecount,todate);
         whereClausecount++;
       }
       else
       {
         whereClause = whereClause +" AND INVOICE_DATE < = :3";
         vo.setWhereClauseParam(whereClausecount,todate);
         whereClausecount++;
       }
     }
     else
     {
        whereClause = " INVOICE_DATE <= :1";
        vo.setWhereClauseParam(whereClausecount,todate);
        whereClausecount++;
     }
    }
   
    vo.setWhereClause(whereClause);
}

6 comments:

  1. Thank you so much this was very helpful. You really know what you are doing. Keep up the good work.

    ReplyDelete
  2. thank you so much its very helpful>>>
    is this the root element "OAQueryBean"

    ReplyDelete
  3. Hi,
    Can you tell me how can we capture the value entered by user in LOV Window.

    ReplyDelete
  4. Thanks a lot for the excellent information. Could you please confirm the way you captured Go button and appended where condition...so does it mean these where conditions will be appeneded along with Standard search SQL.

    Thanks
    Raj

    ReplyDelete
  5. Hi ,

    Could you please tell me that how should i get handle of the buttons of advance table which we are creating in Advance table components --> table actions.

    ReplyDelete