Thursday 28 February 2013

calling procedure in Controller



      if (paramOAPageContext.getParameter("submit_button_id") != null)
      {
        OAApplicationModule localOAApplicationModule2 = paramOAPageContext.getApplicationModule(paramOAWebBean);
         localNumber = null;
         try {
           localNumber = new Number(paramOAPageContext.getDecryptedParameter("ReportHeaderId"));
         }
         catch (SQLException localSQLException2)
         {
         }
       
         if (localNumber != null)
         {
         OADBTransactionImpl  dbtrx =   (OADBTransactionImpl)localOAApplicationModule2.getOADBTransaction();
         String message_out = null;
          String str = "BEGIN xx_custom_pkg.xx_proc( p_report_header_id => :1 , p_message => :2 );END; ";
          CallableStatement localCallableStatement = dbtrx.createCallableStatement(str, 1);
          try
          {
            localCallableStatement.setInt(1, localNumber.intValue());
            localCallableStatement.registerOutParameter(2, Types.VARCHAR);
            localCallableStatement.execute();
            message_out = localCallableStatement.getString(2);
          }
          catch (SQLException localException2)
          {
              paramOAPageContext.writeDiagnostics(this,"abhishek > catch "+localException2,6);
          }
       
         }
}

Tuesday 26 February 2013

create a submit button on page


add the code in process request for adding a submit button dynamically, can then catch the event in processformrequest.

 public void processRequest(OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    {
OASubmitButtonBean xx_submitButton =(OASubmitButtonBean)createWebBean(paramOAPageContext,OAWebBeanConstants.BUTTON_SUBMIT_BEAN, null, "xx_submitButton");
        xx_submitButton.setLabel("NEW_BUTTON");
        xx_submitButton.setText("NEW_BUTTON");
        xx_submitButton.setID("NEW_BUTTON");
        paramOAWebBean.addIndexedChild(xx_submitButton);
     
        super.processRequest(paramOAPageContext, paramOAWebBean);
    }


in PFR

        if (oapagecontext.getParameter("xx_submitButton")!= null)
        {
            try
            {
            NavigationUtility.forwardToPage(oapagecontext, "GeneralInformationPG", null);
            }
            catch(Exception e2)
            {
                oapagecontext.writeDiagnostics(this, "abhishek > xx_button is clicked> catch"+e2, 6); 
            }
        }

View Object on the fly in VORowImpl class


    public String xxfield()
    {
    Number HeaderId = getReportHeaderId();
    String s2= null;

OAApplicationModuleImpl localOAApplicationModuleImpl = (OAApplicationModuleImpl)getApplicationModule();

OADBTransactionImpl localOADBTransactionImpl = (OADBTransactionImpl)localOAApplicationModuleImpl.getOADBTransaction();

     String s1= " select attribute11 from ap_expense_report_headers_all where report_header_id = :1 ";
   
        if (localOAApplicationModuleImpl.findViewObject("xxProjectVO") != null)
{
    oracle.jbo.ViewObject viewobject =  localOAApplicationModuleImpl.findViewObject("xxProjectVO");
            viewobject.remove();
        }
     
        oracle.jbo.ViewObject viewobject = localOAApplicationModuleImpl.createViewObjectFromQueryStmt("xxProjectVO", s1);

        viewobject.setWhereClauseParam(0, HeaderId);
        Object obj = null;
        viewobject.executeQuery();
        if (viewobject.hasNext())
        {
            oracle.jbo.Row row = viewobject.next();
            if (row.getAttribute(0) != null) {
                try {
                    s2 = row.getAttribute(0).toString();
                } catch (Exception E2) {
                }
            }
        }
        viewobject.remove();
        return s2;
    }

Catching the OAException.wrapperException


warp exceptions can be caught using the below code


  OAException t1 = OAException.wrapperException(localException);
  paramOAPageContext.writeDiagnostics(this,"abhishek> "+t1.getExceptions(),6);
  Throwable athrowable[] = t1.getExceptions();

 if (athrowable != null)
   {
 paramOAPageContext.writeDiagnostics(this,"abhishek > "+athrowable.length,6);
         for(int i = 0; i < athrowable.length; i++)
                 {                          
                   if(athrowable[i] instanceof OAException)
                   {
paramOAPageContext.writeDiagnostics(this,"abhishek > "+i,6);
paramOAPageContext.writeDiagnostics(this,"abhishek> "+OAException)athrowable[i]).getMessage(),6);
                            }
                        }
                   
                    }

--focus on the method getExceptions()