Co Ext

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

Selecting parent class

Exmaple 2_

We need to take class file


Create a same folder in MYCLASSES as shown in below screen shot
Once created move class file in the particular path

Create Workspace (ws),project and ne java file


Extends to which standard CO file
Here we will not the process requestr and process form request we we
need add them mannualy.

Controller Extension in OAF


By PRajkumar on Jul 15, 2012

Oracle does not recommend that customers extend controller objects associated with regions or
webbeans in shipped E-Business Suite product pages.
Controller class (oracle.apps.fnd.framework.webui.OAControllerImpl) methods should
effectively be considered private, since their implementation is subject to change. Controller
extensions are therefore not considered to be durable between upgrades.
If it is absolutely essential to handle custom form submit events on a shipped product page,
processFormRequest() is the only method that should be overriden in a controller class,
although the risks outlined above still apply.

Let us try to Extend Controller in OAF Page –


Create one search page as explained in below link –
https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page
In this exercise I am going to extend CO of SearchPG. First lets create CO for SearchPG.
Right Click PageLayoutRN under SearchPG page > Set New Controller 
Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui
Class Name --  SearchCO
Now we will extend this newly created CO under this exercise.  
The purpose of this exercise is to modify the VO query of results table. I have changed
theColumn1 and Column2 fields Property Selective Search Criteria as False.
Now when we click on Go button all the records are displaying in the results table and our
OBJECTIVE is to bind the VO query of results table in such a way that in
result Column1 valueval5 and Column2 value val6 should not come as result on click Go
button

 
 

Now for knowing which controller to extend we click on "About This Page" Link and select
Expand All. Here we can see the Name of the controller that we need to extend

1. Create a New Workspace and Project


File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarCOExtensionDemo
Automatically a new OA Project will also be created
Project Name -- COExtensionDemo
Default Package -- prajkumar.oracle.apps.fnd.coextensiondemo

2. Create a New Java Class


Right Click on COExtensionDemo > New > General > Java Class
Name -- ExtendedCO
Package -- prajkumar.oracle.apps.fnd.coextensiondemo.server
Extends -- prajkumar.oracle.apps.fnd.searchdemo.webui.SearchCO

 
Note -- Give the Name of your Extended Class give its package path and in the extends property
select base class
 

3. Write below logic in ExtendedCO Java Class


package prajkumar.oracle.apps.fnd.coextensiondemo.webui; 
      
import prajkumar.oracle.apps.fnd.searchdemo.webui.SearchCO;
import oracle.apps.fnd.framework.webui.OAPageContext; 
import oracle.apps.fnd.framework.webui.beans.OAWebBean; 
import oracle.apps.fnd.framework.OAApplicationModule; 
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean; 
import prajkumar.oracle.apps.fnd.searchdemo.server.SearchVOImpl; 
  
public class XXItemSearchCO extends ItemSearchCO 

 public XXItemSearchCO() 
 { 
 }  
         
 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)  
 {  
  super.processFormRequest(pageContext, webBean);  
  OAApplicationModule am = pageContext.getApplicationModule(webBean);  
  OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");  
      
  //Capturing Go Button ID  
  String go = queryBean.getGoButtonName();  
             
  //If its Not NULL which mean user has pressed "Go" Button  
  if(pageContext.getParameter(go)!=null)  
  {  
   // Setting whereClause at Runtime to restrict the query   
   SearchVOImpl vo = (SearchVOImpl)am.findViewObject("SearchVO1");  
   vo.setWhereClause(null);  
   vo.setWhereClause("Column1 <>:1 AND Column2 <>:2"); 
   vo.setWhereClauseParam(0,"val5"); 
   vo.setWhereClauseParam(1,"val6"); 
  } 
 } 
}

4. Attach new controller to SearchPG through personalization


Click on Personalize Page link on top right hand side of your page

Note -- If you are not able to see this link then go through below link –
https://blogs.oracle.com/prajkumar/entry/how_to_enable_personalization_link

 
Click on Complete View -> Expand All -> Click on personalize icon next to Page Layout

Now at site level give the path of extended controller as we are extending the controller at SITE
LEVEL
prajkumar.oracle.apps.fnd.coextensiondemo.webui.ExtendedCO

 
 

Click Apply -> Return to Application

5. Congratulation you have successfully finished. Run Your SearchPG page and Test Your
Work

 
 

Click Go
Note – Record with Column1 value val5 and Column2 value val6 is not coming in result

 
 
How to extend a standard controller CO?

I have a standard page in HRMS module and  have a business requirement to have additional check(Validations) to
be performed before i click Transfer button. Transfer button Will have a standard controller.

How to find the controller Name?


Click About this page hyperlink displayed at bottom of the page where your controller has to be extended.

Note: FND: Diagnostics (FND_DIAGNOSTICS) profile option to Yes to render the "About this page" link at the bottom
of each OA Framework-based page. 

1)Unbook the Business components hierarchy


2)It will display all the BC4J components of the OA page.
3)Find the controller at $JAVA_TOP/oracle/apps/per/wpm/objectives/webui
4)Download the controllerCO.class file from "oracle/apps/per/wpm/objectives/webui" to your local system. Your
controller will be applicable based on the application top.
5)Decompile the class file to get java file using CAVAJ utility.
6)Open the Original Java file and Start modify the processFormRequest( ) Method. I have highlighted the changes
done to achieve the business requirement.

 package xx.oracle.apps.per.wpm.objectives.webui;

import com.sun.java.util.collections.HashMap;
import java.io.Serializable;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;
import oracle.apps.per.selfservice.common.SSHRParams;
import oracle.jbo.domain.Number;
import oracle.apps.per.wpm.objectives.webui.*;
import oracle.apps.fnd.framework.OAFwkConstants;
import oracle.apps.fnd.framework.server.OADBTransaction; //to establish DB connection
import java.sql.CallableStatement; //to execute a package.procedure
import java.sql.Types;//used for type conversions and VARCHAR2

// Referenced classes of package oracle.apps.per.wpm.objectives.webui:


//            ObjectivesPageCO

public class XXSetObjectivesPageCO extends SetObjectivesPageCO


{

    public static final String RCS_ID = "$Header:" +


" ship $"
;
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header:" +
" ship $"
, "oracle.apps.per.wpm.objectives.webui");

    public XXSetObjectivesPageCO()


    {
           //Constructor;
    }

    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)


    {
    
      super.processRequest(oapagecontext, oawebbean);
    //I need standard processRequest method to be executed first.
    }

    
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    {
      String p_return_msg  = null;
      if(oapagecontext.getParameter("MgrTransfer") != null) //This is the Transfer Button ID name
       {
        OADBTransaction tx = oapagecontext.getRootApplicationModule().getOADBTransaction();
     
                  String sql="BEGIN " +
                 "XXValidateProc("+
                                   "p_param_1=> :1,"+     
                                   "p_return_msg => :2);"+
                                   "       END;";            
          CallableStatement cStmt = (CallableStatement)tx.createCallableStatement(sql, 1);
          if(cStmt!=null)  
               { 
                         try {  
                        
                         cStmt.setString(1,oapagecontext.getDecryptedParameter("p_param_1"));       
                         cStmt.registerOutParameter(2,Types.VARCHAR);                             
                         cStmt.execute();                                                            
                         p_return_msg = cStmt.getString(2);                                                   
                         cStmt.close();                                                              
                         }
                        catch(Exception e)
                        {
                          throw new OAException("SBM: Error Calling XXValidateProc" + e.toString(),OAException.ERROR);
                        }
                                          
                }
        if(!p_return_msg.equalsIgnoreCase("No Errors")){
                  throw new OAException(p_return_msg,OAException.ERROR);                                            
        }
        else
        {
                         super.processFormRequest(oapagecontext, oawebbean);
        }        
        
      
    }
    else

   { //In case of any exception in the custom procedure, I want the standard controller method's to be called.
     super.processFormRequest(oapagecontext, oawebbean);
   }      
    }
    }
    
Migration of OA Controller Extension

1)Create a folder under $JAVA_TOP xx/oracle/apps/per/wpm/objectives/webui;


2)Move the  XXSetObjectivesPageCO.java to the above location.
3)Compile the Java using javac  XXSetObjectivesPageCO.java
4)Once compilation is done successfully.
5) Goto the page where the Controller is extended. Click Personalize Page Option.

Note: Personalize Self-service Defn (FND_CUSTOM_OA_DEFINTION) profile option should be enabled. 

 Go to The regions where controller is got extended. Inherit the Controller location as 
xx/oracle/apps/per/wpm/objectives/webui/XXSetObjectivesPageCO

Controller Extension is Done :)

You might also like