Saturday, 28 March 2015

OAF: Sample Code to create Dynamic VO in OA Framework

In some cases, we need to create Dynamic View Object in OA Framework. The sample code to create a dynamic View Object is given below.

 ViewObject dynamicViewObject = appModule.findViewObject("XXDynamicVO");  
 if(dynamicViewObject == null)  
 {  
  String voQuery = " SELECT USER_NAME " +  
                                " FROM fnd_users FU " +  
                                " WHERE FU.user_id = :1 ";  
  customViewObject = appModule.createViewObjectFromQueryStmt("XXDynamicVO",voQuery);  
 }  
 if(customViewObject != null)  
 {  
  customViewObject.setWhereClause(null);  
  customViewObject.setWhereClauseParams(null);  
  customViewObject.setWhereClauseParam(0,userID);  
  customViewObject.executeQuery();  
  Row customViewObjectRow = customViewObject.first();  
  if(customViewObjectRow != null)  
  {  
       String userName = (String)customViewObjectRow.getAttribute(0);  
       writeLog(pageContext,"UserName:" + userName);  
  }  
 }  

Feel free to point out if anything is missing/wrong in this blog.

No comments:

Post a Comment