OAF Useful Codes

Embed Size (px)

DESCRIPTION

OAF Useful Codes

Citation preview

//Creating handle of Generic AM in COOAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);//Converting generic AM handle to specific custom AMCreate handle of generic AM as above, thenDocumentAMImpl documentAM = (DocumentAMImpl)oaapplicationmodule;//Creating handle of VO in CO using generic AMPoLinesMergeVOImpl localViewLine = (PoLinesMergeVOImpl)oaapplicationmodule.findViewObject("PoLinesMergeVO");//Creating handle of VO in CO using specific AMPoHeaderMergeVOImpl headerVO = documentAM.getPoHeaderMergeVO();//Creating handle of Row1. PoHeaderMergeVORowImpl headerRow = (PoHeaderMergeVORowImpl)headerVO.getCurrentRow();2. PoHeaderMergeVORowImpl headerRow = (PoHeaderMergeVORowImpl)headerVO.first();//Creating handle of Transaction in COOADBTransaction txn = oaapplicationmodule.getOADBTransaction();//Checking button click eventif (pageContext.getParameter("SaveButton") != null) { //CustomCode }//Checking PPR eventif ("deletePartner".equals(pageContext.getParameter(EVENT_PARAM))) { //CustomCode }//Looping through Rows for (linesRow = (PoLinesMergeVORowImpl)linesVO.first(); linesRow != null; linesRow = (PoLinesMergeVORowImpl)linesVO.next()) { }//Adding Diagnostics in COif (oapagecontext.isLoggingEnabled(1)) { oapagecontext.writeDiagnostics(this, "DefaultCommunicatinMethodUpdated:" + oapagecontext.getTransientSessionValue("DefaultCommunicatinMethodUpdated"), 1);}//Adding diagnostics in AMOADBTransactionImpl txn = (OADBTransactionImpl)((OAApplicationModule)documentAM).getOADBTransaction();if (txn.isLoggingEnabled(1)) txn.writeDiagnostics(this, "Your Message", 1);//Querying VO with ParametersorgAssignmentVO.setWhereClauseParams(null);orgAssignmentVO.setWhereClauseParam(0, strPOHeaderId);orgAssignmentVO.setWhereClauseParam(1, txn.getValue("REFORGID"));orgAssignmentVO.executeQuery();//Adding whereclause in VOString strWhereClause = new String();strWhereClause = "PO_HEADER_ID=" + strPOHeaderId;tableVO.setWhereClause(null);tableVO.setWhereClauseParams(null);tableVO.setWhereClause(strWhereClause);tableVO.executeQuery();//Getting next value of sequenceoracle.jbo.domain.Number dashboardId = txn.getSequenceValue("_SEQUENCENAME_S");//Creating handle of Bean and setting its propertiesOASubmitButtonBean updateButton = (OASubmitButtonBean)oawebbean.findChildRecursive("UpdateButton");updateButton.setRendered(Boolean.FALSE);//Getting value of profileString 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))) { //Custom Code }//Checking LOV Eventif (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 handle of Rowif ("deletePartner".equals(pageContext.getParameter(EVENT_PARAM))) { //Getting row reference String strRowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);PartnerDetailsREFVORowImpl partnerRow = (PartnerDetailsREFVORowImpl)((OAApplicationModule)documentAM).findRowByRef(strRowReference);partnerRow.remove();}//Setting Org context oadbtransaction.setMultiOrgPolicyContext("S", new Long(strOrgId).longValue()); //Callable statement ExampleOADBTransaction 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 ProcedureOADBTransaction txn = (documentAM).getOADBTransaction(); Connection connection = txn.getJdbcConnection(); OracleCallableStatement callableStatement = null; try { callableStatement = (OracleCallableStatement)connection.prepareCall("BEGIN " + strProcedureToBeInvoked + "; END;"); callableStatement.executeUpdate(); } catch (Exception exception) { throw OAException.wrapperException(exception); } finally { try { if (callableStatement != null) { callableStatement.close(); } } catch (Exception exception1) { throw OAException.wrapperException(exception1); } }