Total Pageviews

Wednesday, July 13, 2011

Add Processing Page Access to Launching Page

In the page that initiates the long-running process, add code to instantiate and navigate to the processing page
as shown in the example below.  (Taken from Oracle Developers Guide)

import oracle.apps.fnd.framework.webui.OAProcessingPage;

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
   super.processFormRequest(pageContext, webBean); 

   // This example assumes a submit button named "StartProcess" initiates the long-running process.
   if (pageContext.getParameter("StartProcess")!= null) 
   {
     // Create the processing page and pass it the fully qualified name of the controller that
     // you created to launch the process.
     OAProcessingPage page =  new
OAProcessingPage("oracle.apps.fnd.toolbox.samplelib.webui.processCO");

     // The concise message is displayed in bold and should briefly describe the process.
     // NOTE: never hard-code text display values as shown here.  Always use message dictionary.     
     page.setConciseMessage("This is the concise processing page message.");

     // The detailed message displays below the concise message in plain text.  It provides
     // additional information about what's happening.
     page.setDetailedMessage("This is the detailed message which should explain what's happening.");

     // This is displayed in the processing page title.
     page.setProcessName("<Process Name>");

     // Forward to the processing page.  Note that the OA Framework assumes you
   //  are retaining  the root application module.  Since we haven't specified a different root AM on
     // the processing page, the OA Framework assumes it uses the same root AM as the launching page.
     pageContext.forwardToProcessingPage(page); 
   }
}

Friday, July 8, 2011

Call Procedure in OAF (1 input, 1 output parameter)

            String sql = "BEGIN xx_custom_pkg.custom_prc (:1,:2); END;";
            try {
                OracleCallableStatement cs =
                    (OracleCallableStatement)oam.getOADBTransaction().createCallableStatement(sql,
                                                                                              2);
                ((OracleCallableStatement)cs.registerOutParameter(2,
                                                                  Types.VARCHAR,
                                                                  0, 2000));
                cs.setString(1, xxAttribute1Value);
                cs.execute();
                String outParamValue = cs.getString(1);
                pageContext.writeDiagnostics(this,
                                             "Result is:" + outParamValue,
                                             OAFwkConstants.PROCEDURE);
                cs.close();
            } catch (Exception ex) {
                pageContext.writeDiagnostics(this, "Error:" + ex.toString(),
                                             OAFwkConstants.PROCEDURE);
            }

Wednesday, July 6, 2011

Call Procedure in OAF (2 input parameters)

Call a custom procedure. Two input parameters of type Varchar:
 OAApplicationModule oam =  pageContext.getApplicationModule(webBean);

 String sql =  "BEGIN xx_custom_pkg.custom_prc (:1,:2); END;";
                    try {
                        OracleCallableStatement cs =
                            (OracleCallableStatement)oam.getOADBTransaction().createCallableStatement(sql,
                                                                                                      2);
                        cs.setString(1, xxAttribute1Value);
                        cs.setString(2, xxAttribute2Value);
                        cs.execute();
                        cs.close();
                      }
                 catch (Exception ex) {
                        pageContext.writeDiagnostics(this,
                                                     "Error:" + ex.toString(),
                                                     OAFwkConstants.PROCEDURE);
                    }

Call Function in OAF

The segment below calls a custom function with 1 input parameter of type Varchar and returns a Varchar :

   OAApplicationModule oam = pageContext.getApplicationModule(webBean);  

   String sql =   "BEGIN :1 := xx_custom_pkg.call_custom_function (:2); END;";

  OracleCallableStatement cs =
                            (OracleCallableStatement)oam.getOADBTransaction().createCallableStatement(sql,2);

                        try {
                             //Register your function output...
                            cs.registerOutParameter(1, Types.VARCHAR, 0, 2000);
                            //Your input parameter below...
                            cs.setString(2, LinesRow.getAttribute("ReportLineId").toString());
                            cs.execute();
                            String p_res = cs.getString(1);
                            cs.close();       
                            }
                        catch (Exception ex) {
                                        pageContext.writeDiagnostics(this,
                                                                     "Error:" + ex.toString(),
                                                                     OAFwkConstants.PROCEDURE);
                           }                    

Create Tip Messages

Personalize the page:
The output will look like:





Second type of Tip Message:
And the output:

Tuesday, July 5, 2011

Returns a date string in the users date format

 /*
     * Returns a date string in the users date format
     *
     * @param nlsServ instance of OANLSServices
     * @param dateStr string in 'dd-mm-yyyy' format
     */
    public static String stringToDateString(OANLSServices nlsServ, String dateStr) {

      if (dateStr != null && !dateStr.equals(""))
      {
        Date date = null;
        if (databaseDateFormat != null) {
          try {
            date = databaseDateFormat.parse(dateStr);
          } catch (ParseException e) {
          }
        }

        if (date != null)
          return nlsServ.dateToString(date);
      }

      return null;
    }