0% found this document useful (0 votes)
276 views3 pages

OAF Useful Codes

1. The document shows how to create handles for various Oracle Application objects like ApplicationModule, ViewObjects, Rows, and Transactions in Oracle Application Express. 2. It also demonstrates how to perform operations like querying data, adding/updating rows, executing stored procedures and functions, setting parameters and profiles. 3. Diagnostics and error handling techniques like exception wrapping are also covered.

Uploaded by

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

OAF Useful Codes

1. The document shows how to create handles for various Oracle Application objects like ApplicationModule, ViewObjects, Rows, and Transactions in Oracle Application Express. 2. It also demonstrates how to perform operations like querying data, adding/updating rows, executing stored procedures and functions, setting parameters and profiles. 3. Diagnostics and error handling techniques like exception wrapping are also covered.

Uploaded by

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

//Creating handle of Generic AM in CO

OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oaw


ebbean);
//Converting generic AM handle to specific custom AM
Create handle of generic AM as above, then
DocumentAMImpl documentAM = (DocumentAMImpl)oaapplicationmodule;
//Creating handle of VO in CO using generic AM
PoLinesMergeVOImpl localViewLine =
(PoLinesMergeVOImpl)oaapplicationmodule.findViewObject("PoLinesM
ergeVO");
//Creating handle of VO in CO using specific AM
PoHeaderMergeVOImpl headerVO = documentAM.getPoHeaderMergeVO();
//Creating handle of Row
1. PoHeaderMergeVORowImpl headerRow = (PoHeaderMergeVORowImpl)headerVO.getCurren
tRow();
2. PoHeaderMergeVORowImpl headerRow = (PoHeaderMergeVORowImpl)headerVO.first();
//Creating handle of Transaction in CO
OADBTransaction txn = oaapplicationmodule.getOADBTransaction();
//Checking button click event
if (pageContext.getParameter("SaveButton") != null) { //CustomCode }
//Checking PPR event
if ("deletePartner".equals(pageContext.getParameter(EVENT_PARAM))) { //CustomCod
e }
//Looping through Rows
for (linesRow = (PoLinesMergeVORowImpl)linesVO.first();
linesRow != null;
linesRow = (PoLinesMergeVORowImpl)linesVO.next()) { }
//Adding Diagnostics in CO
if (oapagecontext.isLoggingEnabled(1)) {
oapagecontext.writeDiagnostics(this,
"DefaultCommunicatinMethodUpdated:" +
oapagecontext.getTransientSessionValu
e("DefaultCommunicatinMethodUpdated"),
1);
}
//Adding diagnostics in AM
OADBTransactionImpl txn =
(OADBTransactionImpl)((OAApplicationModule)documentAM).getOADBTransa
ction();
if (txn.isLoggingEnabled(1))
txn.writeDiagnostics(this, "Your Message", 1);
//Querying VO with Parameters
orgAssignmentVO.setWhereClauseParams(null);
orgAssignmentVO.setWhereClauseParam(0, strPOHeaderId);
orgAssignmentVO.setWhereClauseParam(1, txn.getValue("REFORGID"));
orgAssignmentVO.executeQuery();

//Adding whereclause in VO
String strWhereClause = new String();
strWhereClause = "PO_HEADER_ID=" + strPOHeaderId;
tableVO.setWhereClause(null);
tableVO.setWhereClauseParams(null);
tableVO.setWhereClause(strWhereClause);
tableVO.executeQuery();
//Getting next value of sequence
oracle.jbo.domain.Number dashboardId =
txn.getSequenceValue("_SEQUENCENAME_S");
//Creating handle of Bean and setting its properties
OASubmitButtonBean updateButton = (OASubmitButtonBean)oawebbean.findChildRecursi
ve("UpdateButton");
updateButton.setRendered(Boolean.FALSE);
//Getting value of profile
String strProfileValue =
pageContext.getProfile("PROFILE_NAME");
//Checking Addrow button click in Advanced Table
if ("PartnerDetailsAdvTbl".equals(pageContext.getParameter(SOURCE_PARAM)
) &&
ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM))) { //Cu
stom Code }
//Checking LOV Event
if (pageContext.isLovEvent()) {
String strLovInputSource =
(String)pageContext.getLovInputSourceId();
if ((null != strLovInputSource) &&
((("LOV_BEAN_ID".equals(strLovInputSource)))) { //Custom Code }
}
//Checking PPR event like delete image click in Advanced Table And Getting handl
e of Row
if ("deletePartner".equals(pageContext.getParameter(EVENT_PARAM))) {
//Getting row reference
String strRowReference =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REF
ERENCE);
PartnerDetailsREFVORowImpl partnerRow =
(PartnerDetailsREFVORowImpl)((OAApplicationModule)documentAM).fi
ndRowByRef(strRowReference);
partnerRow.remove();
}
//Setting Org context
oadbtransaction.setMultiOrgPolicyContext("S",
new Long(strOrgId).longValue())
;
//Callable statement Example
OADBTransaction txn =
((OAApplicationModuleImpl)documentAM).getOADBTransaction();
String strValueBasis = null;
String strSQLQuery =

"select order_type_lookup_Code from po_line_Types where line_type ='


" +
linesRow.getLineType() + "'";
OracleCallableStatement statement =
(OracleCallableStatement)txn.createCallableStatement(strSQLQuery,
1);
try {
statement.execute();
ResultSet resultSet = statement.getResultSet();
if (resultSet.next()) {
strValueBasis = resultSet.getString(1);
}
} catch (SQLException sqlExp) {
throw OAException.wrapperException(sqlExp);
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException sqlEx) {
throw OAException.wrapperException(sqlEx);
}
}
//Callable Statement Example for Procedure
OADBTransaction txn = (documentAM).getOADBTransaction();
Connection connection = txn.getJdbcConnection();
OracleCallableStatement callableStatement = null;
try {
callableStatement =
(OracleCallableStatement)connection.prepareCall("BEGIN " +
strProcedure
ToBeInvoked +
"; END;");
callableStatement.executeUpdate();
} catch (Exception exception) {
throw OAException.wrapperException(exception);
} finally {
try {
if (callableStatement != null) {
callableStatement.close();
}
} catch (Exception exception1) {
throw OAException.wrapperException(exception1);
}
}

You might also like