Friday, 12 January 2018

How to Create Dynamic LOV in OAF Through Controller Extension


Hi Friends, In this post I will share you the Java code by which you can create a Dynamic LOV in your OAF page.

You have to put this code under controller of the page which controls your LOV field in the page.

Suppose field Supplier Name in the OAF page  has View Object(VO) SuppliersVO for which we want to change its query is existing in the page View Object SuppliersHeadersVO.


Controller Code:-


  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
      super.processRequest(pageContext, webBean);

// Declaring Variable of Supplier_no in Controller

 String Supplier_no = null; 

// This below code gives control in the page so that you can access all the objects of this page.

// appModule is the variable of Application module

 OAApplicationModule appModule = pageContext.getApplicationModule(webBean);

// This below code taking control of SuppliersHeadersVO view object
// vo11 is the View object variable

  OAViewObject vo11 = (OAViewObject)appModule.findViewObject("SuppliersHeadersVO");


//  This query will execute if the upper view object will be find.

  if (vo11 !=null) {

// selecting value on which we will change the View object query

 Supplier_no  = pageContext.getParameter("Attribute11");


        if (Supplier_no!=null)

        {

        String query = "SELECT VENDOR_NAME,SEGMENT1 SUPPLIER_NUMBER"
                      +"FROM PO_VENDORS PV"
                      +"WHERE SEGMENT1=Supplier_no";

                  try
         {
         OAApplicationModule oam = pageContext.getApplicationModule(webBean);
         OAViewObject vo = (OAViewObject)oam.findViewObject("SuppliersVO");
         vo.setFullSqlMode(vo.FULLSQL_MODE_AUGMENTATION);
        vo.setQuery(query);

         // setQuery only sets the new query to the View Object, in order to effect the changes of the query we need to execute the equery using below statement.
         vo.executeQuery();

         }
         catch (Exception e)
         {
          null;
         }   
     
        //end lov dynamic query
        }
}







0 comments:

Post a Comment