Create Method In AM Java Code:-
public String AddNumber(String item1,String item2)
{
OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
String retValues;
// Below I hava created Strring to Call Pl/sql procedure in Begin and end block
String str = "Begin proc_in_oaf.addition(:1,:2,:3); End;";
OracleCallableStatement oraclecallablestatement =
(OracleCallableStatement)oadbtransaction.createCallableStatement(str.toString(), 1);
try{
oraclecallablestatement.setFloat(1, Float.parseFloat(item1) );
oraclecallablestatement.setFloat(2, Float.parseFloat(item2) );
oraclecallablestatement.registerOutParameter(3,Types.VARCHAR);
oraclecallablestatement.execute();
retValues = oraclecallablestatement.getString(3);
}
catch(Exception e)
{
throw OAException.wrapperException(e);
}
return retValues;
}
Call Method In Controller:-
//CalculationAMImpl it is AM name
CalculationAMImpl am1 = (CalculationAMImpl)pageContext.getApplicationModule(webBean);
OAMessageTextInputBean xx = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("item2");
OAMessageTextInputBean xx1 = (OAMessageTextInputBean)webBean.findChildRecursive("item7");
Serializable[] parameters1 = { (Serializable)xx.getValue(pageContext), (Serializable)xx1.getValue(pageContext) };
//here I have Called That Method
String no = (String)am1.invokeMethod("AddNumber",parameters1);
No comments:
Post a Comment