Dyanmically Change VO query in OAF

We often come across the requirement  where View object query needs to be changed Dynamically. In this article we will be briefing out prerequisites steps about how to change query of view object.


1. I'm going to create view Object  XxTestVO with below query .

SELECT 'term_id' NEW_ID, 'name' NEW_NAME
  FROM DUAL
 WHERE 1 = 2

** Important Point : View object whose query needs to be changed dynamically must have same columns and Column names 

For example  , i will be replacing vo query with below query based on certain condition.

Select term_id New_id, Name NEW_NAME from ra_terms 

or 

Select customer_trx_id NEW_ID, customer_Trx_name NEW_NAME from ra_customer_trx_all



2. You can set query both in Process request and Process Form request method based on your requirement. 


  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    XxTestAMImpl am = (XxTestAMImpl)pageContext.getApplicationModule(webBean);  
     voimpl = (XxTestVOImpl)am.findViewObject("XxTestVO1");
     voimpl.setFullSqlMode(voimpl.FULLSQL_MODE_AUGMENTATION);
     voimpl.setQuery("
Select term_id New_id, Name NEW_NAME from ra_terms ");
     voimpl.executeQuery();
}

 FULLSQL_MODE_AUGMENTATION: A full SQL mode that indicates that ViewObject level query augmentation (where-clause, order-by-clause) will be added to the query specified through a call to setQuery()


Following above steps. you view object query will be set dynamically. You can set query based on condition as per the business requirement

Comments

Popular posts from this blog

REST integration built-in OIC to read Large files with size more than 10MB

Basic Concepts of OAF (Oracle Applications FrameWork )