0% found this document useful (0 votes)
50 views

OAF Scripts and Codes

The document provides examples of common Oracle Application Framework (OAF) developer tasks like initializing a view object, committing/rolling back transactions, calling a PL/SQL procedure, firing a partial page refresh event, and more. Code snippets show how to perform operations like creating a record, initializing a query, and calling another page in OAF.

Uploaded by

arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

OAF Scripts and Codes

The document provides examples of common Oracle Application Framework (OAF) developer tasks like initializing a view object, committing/rolling back transactions, calling a PL/SQL procedure, firing a partial page refresh event, and more. Code snippets show how to perform operations like creating a record, initializing a query, and calling another page in OAF.

Uploaded by

arif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 9

1. http://prajkumarblog.

com/oaf-developer-guide/

-------------------------- Initialize VO -------------

public void initXXPoHeaderVO()

XXPoHeaderVOImpl vo = getXXPoHeaderVO1();

XXPoHeaderVORowImpl row = null;

row = (XXPoHeaderVO)vo.createRow();

row.setNewRowState(row.STATUS_INITIALIZED);

vo.insertRow(row);

----------------------- RollBack---------------------------

public void rollback() {

getOADBTransaction().rollback();

------------------ Apply------------------------------------

public void apply()

getTransaction().commit();

--------------------------------------------------------------------------------

if (pageContext.getParameter("Apply") != null)

{
OAApplicationModule am = pageContext.getRootApplicationModule();

//No need for any special exception handling. You can just display the

//confirmation message because the OAF won't reach this code if the post/commit

//fails.

am.invokeMethod("apply");

OAException confirmMessage =

new OAException("ICX", "FWK_TBX_T_SUPPLIER_CREATE_CONF", null,

OAException.CONFIRMATION, null);

pageContext.putDialogMessage(confirmMessage);

-------------------------------------------------------------------------------------------

------------------------- Cancel / Back-----------------------------

else if (pageContext.getParameter("Cancel") != null)

am.invokeMethod("rollback");

pageContext.forwardImmediately("OA.jsp?
page=/search/oracle/apps/PO/searchdemoPRJ/webui/searchPG",

null,

OAWebBeanConstants.KEEP_MENU_CONTEXT,

null,

null,

false, // retain AM

OAWebBeanConstants.ADD_BREAD_CRUMB_NO);

--------------------------------------How to get VO from AM---------------------------------------


OAViewObject objAssessmentVO = (OAViewObject) yourAM.findViewObject ("yourVO");

-------------------------------------------------------------------------------------------------------------

MtlLotNumbersVOImpl vo= (MtlLotNumbersVOImpl)findViewObject("MtlLotNumbersVO1");

MtlLotNumbersVORowImpl voi=(MtlLotNumbersVORowImpl)(vo.getCurrentRow());

mLotDetailValuesHT.put("StatusId",voi.getStatusId());

-------------------------InitQuery----------------------------------------------

public void initQuery (String employeeNumber)

if ((employeeNumber! = null) &&

(! ("". equals (employeeNumber.trim ()))))

//Do the following conversion for type consistency.

Number empNum = null;

try

empNum = new Number (employeeNumber);

catch (Exception e)

throw new OAException ("AK", "FWK_TBX_INVALID_EMP_NUMBER");

setWhereClause ("EMPLOYEE_ID =: 1");

setWhereClauseParams (null);//Always reset


setWhereClauseParam (0, empNum);

executeQuery ();

}//end initQuery ()

-----------------------------------------------------------------------------------------------------

/***************************************** ****************************

* Initializes the detail employee query.

****************************** *************************** */

public void initDetails (String employeeNumber)

EmpfullVOImpl vo = getEmpfullVO1 ();

if (vo == null)

MessageToken [] errTokens = {new MessageToken ("OBJECT_NAME", "EmployeeFullVO1")};

throw new OAException ("AK", "FWK_TBX_OBJECT_NOT_FOUND", errTokens);

vo.initQuery (employeeNumber);

}//end initDetails ()

---------------------------------------------- Create Record-----------------------------------------------

public void createEmployee ()

OAViewObject vo = (OAViewObject) getEmpfullVO1 ();


//Per the coding standards, this is the proper way to initialize a

//VO that is used for both inserts and queries. See View Objects

//in Detail in the Developer's Guide for additional information.

if (! vo.isPreparedForExecution ())

vo.executeQuery ();

Row row = vo.createRow ();

vo.insertRow (row);

//Required per OA Framework Model Coding Standard M69

row.setNewRowState (Row.STATUS_INITIALIZED);

}//end createEmployee ()

---------------------------Calling Page-----------------------------------------------

pageContext.setForwardURL("OA.jsp?page=/lyf4/oracle/apps/ak/emp/webui/EmployeePG",

null,

OAWebBeanConstants.KEEP_MENU_CONTEXT,

null,

null,

true,//Retain AM

OAWebBeanConstants.ADD_BREAD_CRUMB_YES,

OAWebBeanConstants.IGNORE_MESSAGES);

---------------------------------------------------------------------------------------------------------------
public void rollbackEmployee()

Transaction txn = getTransaction();

//This small optimization ensures that we don't perform a rollback

//if we don't have to.

if (txn.isDirty())

txn.rollback();

}//end rollbackEmployee()

---------------------------------------Firepartial Event-----------------------------------------------------------

public String firePprEvent(String empNum) {

try {

XxPprDemoVOImpl vo = getXxPprDemoVO1();

vo.setWhereClause(null);

vo.setWhereClauseParams(null);

vo.setWhereClause("EMPNO = :1");

vo.setWhereClauseParam(0, empNum);

vo.setMaxFetchSize(-1);

vo.executeQuery();

XxPprDemoVORowImpl row = (XxPprDemoVORowImpl)vo.first();

if (row == null) {

return "N";

} catch (Exception e) {
e.printStackTrace();

return "Y";

-------------------------doDML---------------------------------------------------------------

protected void doDML(int i, TransactionEvent transactionEvent) {

RowIterator employees = getEmployees();

EmployeeImpl firstEmployee = (EmployeeImpl)employees.first();

try {

firstEmployee.setCommissionPct(new Number(0.99));

} catch (SQLException e) {

throw new JboException(e);

super.doDML(i, transactionEvent);

-----------------------------Calling PL SQL Procedure------------------------------------------------------------

public void callPLSQLProc(Number id,String code,Date currentDate)

OracleCallableStatement callableStatement = null;

try

String callProc = " BEGIN xxaj_pkg.xxaj_proc "+

"(p_id => :1," +


" p_code => :2," +

" p_date => :3," +

" p_commit => :4," +

" x_return_status => :5," +

" x_msg_data => :6," +

" x_msg_count => :7);"+

" END; ";

callableStatement =
(OracleCallableStatement)getOADBTransaction().createCallableStatement(callProc,1);

callableStatement.setNUMBER(1, id);

callableStatement.setString(2, code);

callableStatement.setDATE(3, currentDate);

callableStatement.setString(4, "Y");

callableStatement.registerOutParameter(5,OracleTypes.VARCHAR,255);

callableStatement.registerOutParameter(6,OracleTypes.VARCHAR,255);

callableStatement.registerOutParameter(7,OracleTypes.NUMBER,255);

callableStatement.execute();

String resultMessage = (String)callableStatement.getString(5);

String msgData = (String)callableStatement.getString(6);

catch(Exception e)

e.printStackTrace();

throw new OAException(e.toString(),OAException.ERROR);

finally
{

try

callableStatement.close();

catch(Exception exception2)

throw OAException.wrapperException(exception2);

--------------------------------------------------------------------------------------------------------

You might also like