If we want to call any method of Application Module from Controller class in OA Framework there are two ways to achieve this:
- Using invokeMethod: invokeMethod is the method of OAApplicationModule class it takes three parameters:
- Method Name- Data Type String
- Parameters(Optional)- array of type Serializable
- paramTypes(Optional)- array of datatypes, one to one mapping with parameters.
Example:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
Boolean executeQuery = BooleanUtils.getBoolean(false);
String s3 = pageContext.getParameter(“auctionHeaderId”);
Serializable parameters[] = {s3, executeQuery};
Class paramTypes[] = {String.class, Boolean.class};
am.invokeMethod(“initSummary”, parameters, paramTypes);
- Creating an Interface of Application Module: This method is useful if we have to pass serializable parameters to AM. In this case first we need to create an interface for Application module:
Following are the steps to create Interface of Application Module:
Step 1: Select required AM, right click, from context menu select edit <AMName>
Step 2: Select Client Method option
If we want to call any method of Application Module from Controller class there are two ways to achieve this:
- Using invokeMethod: invokeMethod is the method of OAApplicationModule class it takes three parameters:
- Method Name- Data Type String
- Parameters(Optional)- array of type Serializable
- paramTypes(Optional)- array of datatypes, one to one mapping with parameters.
Example:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
Boolean executeQuery = BooleanUtils.getBoolean(false);
String s3 = pageContext.getParameter(“auctionHeaderId”);
Serializable parameters[] = {s3, executeQuery};
Class paramTypes[] = {String.class, Boolean.class};
am.invokeMethod(“initSummary”, parameters, paramTypes);
- Creating an Interface of Application Module: This method is useful if we have to pass serializable parameters to AM. In this case first we need to create an interface for Application module
Following are the steps to create Interface of Application Module:
Step 1: Select required AM, right click, from context menu select edit <AMName>
Step 2: Select Client Method option
Step 3: In above figure you are able to see methods under available select required methods (methods you want to call without using invokeMethod) and move those to right side and click on Apply and OK.
After this step, Jdeveloper will create one java file name of AM, you can see this Object Navigator:
Contents of that file will be:
package xxbc.oracle.apps.icx;
import oracle.jbo.ApplicationModule;
// —————————————————————
// — File generated by Oracle Business Components for Java.
// —————————————————————
/**
*
* Generated interface. Do not modify.
*/
public interface EmpAM extends ApplicationModule
{
void deleteEmpMethod(String pEmpId);
void createEmpMethod();
void createEmp();
void updateEmpMethod(String pEmpId);
void saveEmpToDatabase();
void rollbackToDatabase();
}
Now to call these methods from your controller you need to add following things to your controller class:
- Import package which contains your Application Module definition to controller class e.g.
Import xxx.oracle.apps.xxx.server;
- Create an object of your Application module
XXEGAAwardByQuoteAM xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);
Where XXEGAAwardByQuoteAM is Interface class of Application module XXEGAAwardByQuoteAM.
- Call your method like:
<AMObject>.<method>
Example:
Import XXEGA.oracle.apps.pon.awardbyqt.server.XXEGAAwardByQuoteAMImpl;
…
processFormRequest(….)
{
XXEGAAwardByQuoteAMImpl xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);
Number s5 = xxegaawardbyquoteam.get_msgCount();
}
Contents of that file will be:
package xxbc.oracle.apps.icx;
import oracle.jbo.ApplicationModule;
// —————————————————————
// — File generated by Oracle Business Components for Java.
// —————————————————————
/**
*
* Generated interface. Do not modify.
*/
public interface EmpAM extends ApplicationModule
{
void deleteEmpMethod(String pEmpId);
void createEmpMethod();
void createEmp();
void updateEmpMethod(String pEmpId);
void saveEmpToDatabase();
void rollbackToDatabase();
}
Now to call these methods from your controller you need to add following things to your controller class:
· Import package which contains your Application Module definition to controller class e.g.
Import xxx.oracle.apps.xxx.server;
· Create an object of your Application module
XXEGAAwardByQuoteAM xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);
Where XXEGAAwardByQuoteAM is Interface class of Application module XXEGAAwardByQuoteAM.
· Call your method like:
<AMObject>.<method>
Example:
Import XXEGA.oracle.apps.pon.awardbyqt.server.XXEGAAwardByQuoteAMImpl;
…
processFormRequest(….)
{
XXEGAAwardByQuoteAMImpl xxegaawardbyquoteam = (XXEGAAwardByQuoteAMImpl)pageContext.getApplicationModule(webBean);
Number s5 = xxegaawardbyquoteam.get_msgCount();
}
Pingback: 2010 in review « Dinesh Nair's Oracle EBS Blog