Wednesday 27 July 2011

Changing the Total Label in OAF

Call this method from processRequest(---,----) Method


 private void setReportSumText(OAPageContext pageContext, OAWebBean webBean)
  {
    OAAdvancedTableBean advancedTableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("BuyerTableRN");
    advancedTableBean.prepareForRendering(pageContext);
    if (advancedTableBean != null)
    {
      OATableFooterBean tableFooterBean = (OATableFooterBean)advancedTableBean.getFooter();
      if(tableFooterBean != null)
      {
        OATotalRowBean totalRowBean = (OATotalRowBean)tableFooterBean.getTotal();
        if(totalRowBean != null)
        {
          totalRowBean.setText("Report-Sum");
        }
      }
   }
  }

Number Formatting in OAF.......



Call this method from ProcessRequest (-----,------) method

  private void setNumberFormatter(OAPageContext pageContext, OAWebBean webBean)
   {
      Formatter formatter = new OADecimalValidater("$#,##0.00;($#,##0.00)", "$#,##0.00;($#,##0.00)");
      OAMessageStyledTextBean sumOfColumn = (OAMessageStyledTextBean)webBean.findChildRecursive("SumOfInvoices");//Id of the Item
      OAColumnBean sumColumnBean = (OAColumnBean)webBean.findIndexedChildRecursive("SumOfInvoicesColumn"); // Id of the Column
      if (sumOfColumn != null)
      {
        sumOfColumn.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
        sumOfColumn.setAttributeValue(CURRENCY_CODE,"USD");
        sumColumnBean.setAttributeValue(CURRENCY_CODE,"USD");
        sumColumnBean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
      }
      OAMessageStyledTextBean totInvoiceAmount = (OAMessageStyledTextBean)webBean.findChildRecursive("TotalInvoiceAmount");
      OAColumnBean totInvoiceColumnBean = (OAColumnBean)webBean.findIndexedChildRecursive("TotalInvoiceAmountColumn");
      if (totInvoiceAmount != null)
      {
        totInvoiceAmount.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
        totInvoiceAmount.setAttributeValue(CURRENCY_CODE,"USD");
        totInvoiceColumnBean.setAttributeValue(CURRENCY_CODE,"USD");
        totInvoiceColumnBean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);
      }
   }

Monday 18 July 2011

Adding Custom Html code to the OAF Page

/* adding html code to the OAF page */

Step1: -  Import the OARawTextBean in the controller so we will be able to create handles for it. Import the OARawTextBean bean as shown below.
                 import oracle.apps.fnd.framework.webui.beans.OARawTextBean;
Step2: -  In the processrequest method create a handle for the OARawTextBean and create a String to write the HTML code in it.

OARawTextBean trialRawTextBean = (OARawTextBean)webBean.findChildRecursive(“xxTrialRawTextBean “);
String theHtmlCode = "<html><body><p style= \"font-family:Arial,Helvetica,Geneva,sans-serif:font-size:10pt;color:blue\">This is an example to to show how to add the custom html code to the OAF page "+"</p></body></html>"

Step3:- Set the String variable as the text to the OARawTextBean as shown below and run the page
trialRawTextBean.setText(theHTMLCode);

Step4:- You should be able to see the Text that you have written as shown below in your OAF Page.

Wednesday 13 July 2011

Common CO which is used for across the page

package cisco.oracle.apps.xxcfi.ap.holdtel.webui;

import cisco.oracle.apps.xxcfi.ap.holdtel.common.xxcfiHoldtelConstants;
import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAFormattedTextBean;
import oracle.apps.fnd.framework.webui.beans.OARawTextBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;


/**
 * Controller for ...
 */
public class xxcfiHoldtelCommonCO extends OAControllerImpl implements xxcfiHoldtelConstants
{
  public String purchaseGroupText = null;
  public String managerText = null;
  public String buyerText = null;
  public String supplierText = null;
  public String invoiceText = null;
 
  public static final String RCS_ID="$Header: HoldtelCommonCO.java 1.0 kandkuma $";
  public static final boolean RCS_ID_RECORDED =
  VersionInfo.recordClassVersion(RCS_ID, "cisco.oracle.apps.xxcfi.ap.holdtel.webui");
 
  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    setWelcomePrompt(pageContext, webBean);
    addUserSelectedSearchCriteriaSection(pageContext, webBean);
    setReturnLinkText(pageContext, webBean);
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
  }

/**
   * procedure to set the user name for each page.
   * @param pageContext
   * @param webBean
   */
  private void setWelcomePrompt(OAPageContext pageContext, OAWebBean webBean)
  {
    if(addWelcomePrompt())
    {
      String userName = (String) pageContext.getSessionValue(HOLDTEL_USER_DISPLAY_NAME);
      if(userName == null || "".equals(userName))
      {
        OAApplicationModule holdtelAM = pageContext.getApplicationModule(webBean);
        userName = (String)holdtelAM.invokeMethod("getUserDisplayName");
        pageContext.putSessionValue(HOLDTEL_USER_DISPLAY_NAME, userName);
      }
     
      MessageToken[] tokens = {new MessageToken("USER_NAME", userName ) };
      StringBuffer newPrompt = new StringBuffer(100);
      newPrompt.append(pageContext.getMessage("XXCAP", "XXCFI_AP_HOLDTEL_USR_WLCM_MSG", tokens));
      newPrompt.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
      newPrompt.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
      newPrompt.append(pageContext.getCurrentDBDate().toString());
     
      OAFormattedTextBean userInfoBean = getPageStatusBean(pageContext, webBean);
      if(userInfoBean != null)
      {
        userInfoBean.setText(newPrompt.toString());
      }
    }
  }
  /**
   * procedure to set the welcome prompt for each page.
   * @param pageContext
   * @param webBean
   * @return
   */
  private OAFormattedTextBean getPageStatusBean(OAPageContext pageContext, OAWebBean webBean)
  {
    OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
    OAFormattedTextBean infoText = (OAFormattedTextBean)pageLayout.getUserInfo();
    if(infoText == null)
    {
      infoText = (OAFormattedTextBean)createWebBean(pageContext, OAWebBeanConstants.FORMATTED_TEXT_BEAN, null, "welcomePrompt");
      infoText.setCSSClass("OraPageStampText");
      pageLayout.setUserInfo(infoText);
  }
  return infoText;
}
/**
   * procedure to capture and set the user selected criteria to every page.
   * @param pageContext
   * @param webBean
   */
  private void addUserSelectedSearchCriteriaSection(OAPageContext pageContext, OAWebBean webBean)
  {
    if(addUserSelectedSearchCriteriaRN())
    {
      OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
      OAWebBean searchCriteria = pageLayout.findIndexedChildRecursive("SearchCriteriaRN1");
      if(searchCriteria == null)
        searchCriteria = createWebBean(pageContext, "/cisco/oracle/apps/xxcfi/ap/holdtel/webui/SearchCriteriaRN", "SearchCriteriaRN1", true);
      if(searchCriteria != null)
      {
        OARawTextBean categoryInvoice = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Category-Invoice");
        OARawTextBean categorySupplier = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Category-Supplier");
        OARawTextBean categoryBuyer = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Category-Buyer");
        OARawTextBean categoryInvoiceDetails = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Category-InvoiceDetails");
        OARawTextBean categorySummarByPurchasingManager = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Category-SummarByPurchasingManager");
        OARawTextBean purchaseGroup = (OARawTextBean)searchCriteria.findIndexedChildRecursive("PurchaseGroup");
        OARawTextBean manager = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Manager");
        OARawTextBean buyer = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Buyer");
        OARawTextBean supplier = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Supplier");
        OARawTextBean invoice = (OARawTextBean)searchCriteria.findIndexedChildRecursive("Invoice");
        OARawTextBean linkHint = (OARawTextBean)searchCriteria.findIndexedChildRecursive("LinkHint");

        String reportType = pageContext.getParameter(HOLDTEL_REPORT_TYPE);
        if(HOLDTEL_SUMMARY_REPORT.equals(reportType))
        {
          hideItem(categoryInvoice);
          hideItem(categorySupplier);
          hideItem(categoryBuyer);
          hideItem(categoryInvoiceDetails);
          hideItem(invoice);

          String pGroupName = pageContext.getParameter(HOLDTEL_PURCHASE_GROUP);
          String mgrName = pageContext.getParameter(HOLDTEL_MANAGER_NAME);
          String buyerName = pageContext.getParameter(HOLDTEL_BUYER_NAME);
          String supplierName = pageContext.getParameter(HOLDTEL_SUPPLIER_NAME);
         
          if(isEmpty(pGroupName))
            hideItem(purchaseGroup);
          else
          {
            if(purchaseGroup != null)
            {
              if(purchaseGroupText == null)
                purchaseGroupText = purchaseGroup.getText();
              purchaseGroup.setText(purchaseGroupText+pGroupName);
            }
          }
           
          if(isEmpty(mgrName))
            hideItem(manager);
          else
          {
            if(manager != null)
            {
              if(managerText == null)
                managerText = manager.getText();
              manager.setText(managerText+mgrName);
            }
          }
         
          if(isEmpty(buyerName))
            hideItem(buyer);
          else
          {
            if(buyer != null)
            {
              if(buyerText == null)
                buyerText = buyer.getText();
              buyer.setText(buyerText+buyerName);
            }
          }
         
          if(isEmpty(supplierName))
            hideItem(supplier);
          else
          {
            if(supplier != null)
            {
              if(supplierText == null)
                supplierText = supplier.getText();
              supplier.setText(supplierText+supplierName);
            }
          }
        }
        else if(HOLDTEL_DETAIL_REPORT.equals(reportType))
        {
          hideItem(categorySummarByPurchasingManager);
          hideItem(purchaseGroup);
          hideItem(manager);

          String buyerName = pageContext.getParameter(HOLDTEL_DTL_BUYER_NAME);
          String supplierName = pageContext.getParameter(HOLDTEL_DTL_SUPPLIER_NAME);
          String invoiceNum = pageContext.getParameter(HOLDTEL_INVOICE_NUM);
         
          if(isEmpty(buyerName))
          {
            hideItem(buyer);
            hideItem(categoryBuyer);
          }
          else
          {
            if(buyer != null)
            {
              if(buyerText == null)
                buyerText = buyer.getText();
              buyer.setText(buyerText+buyerName);
            }
          }
         
          if(isEmpty(supplierName))
          {
            hideItem(supplier);
            hideItem(categorySupplier);
          }
          else
          {
            if(supplier != null)
            {
              if(supplierText == null)
                supplierText = supplier.getText();
              supplier.setText(supplierText+supplierName);
            }
          }
         
          if(isEmpty(invoiceNum))
          {
            hideItem(invoice);
            hideItem(categoryInvoice);
            hideItem(categoryInvoiceDetails);
          }
          else
          {
            if(invoice != null)
            {
              if(invoiceText == null)
                invoiceText = invoice.getText();
              invoice.setText(invoiceText+invoiceNum);
            }
          }
        }
        else if(HOLDTEL_EXECUTIVE_REPORT.equals(reportType))
        {
          hideItem(categoryInvoice);
          hideItem(categorySupplier);
          hideItem(categoryBuyer);
          hideItem(categorySummarByPurchasingManager);
          hideItem(purchaseGroup);
          hideItem(manager);
          hideItem(buyer);
          hideItem(supplier);
          hideItem(invoice);
        }
       
        if(linkHint != null)
        {
          String message = pageContext.getMessage("XXCAP", "XXCFI_AP_HOLDTEL_LINK_HINT", null);
          linkHint.setText(message);
        }
        pageLayout.addIndexedChild(searchCriteria);
      }
    }
  }

  protected boolean addUserSelectedSearchCriteriaRN()
  {
    return true;
  }
 
  protected boolean addWelcomePrompt()
  {
    return true;
  }

/**
   * procedure to handle the url parameters.
   * @param pageContext
   * @return
   */
  protected HashMap getURLParams(OAPageContext pageContext)
  {
    HashMap params = new HashMap(20);
    String pGroup = pageContext.getParameter(HOLDTEL_PURCHASE_GROUP);
    String mgrId = pageContext.getParameter(HOLDTEL_MANAGER_ID);
    String buyerId = pageContext.getParameter(HOLDTEL_BUYER_ID);
    String supplierId = pageContext.getParameter(HOLDTEL_SUPPLIER_ID);
    String dtlBuyerId = pageContext.getParameter(HOLDTEL_DTL_BUYER_ID);
    String dtlSupplierId = pageContext.getParameter(HOLDTEL_DTL_SUPPLIER_ID);
    String invoiceId = pageContext.getParameter(HOLDTEL_INVOICE_ID);
    String invoiceNum = pageContext.getParameter(HOLDTEL_INVOICE_NUM);
    String mgrName = pageContext.getParameter(HOLDTEL_MANAGER_NAME);
    String buyerName = pageContext.getParameter(HOLDTEL_BUYER_NAME);
    String supplierName = pageContext.getParameter(HOLDTEL_SUPPLIER_NAME);
    String dtlBuyerName = pageContext.getParameter(HOLDTEL_DTL_BUYER_NAME);
    String dtlSupplierName = pageContext.getParameter(HOLDTEL_DTL_SUPPLIER_NAME);
    String selPGroup = pageContext.getParameter(HOLDTEL_SELECTED_PURCHASE_GROUP);
    String selMgrId = pageContext.getParameter(HOLDTEL_SELECTED_MANAGER_ID);
    String selBuyerId = pageContext.getParameter(HOLDTEL_SELECTED_BUYER_ID);
    String selSupplierId = pageContext.getParameter(HOLDTEL_SELECTED_SUPPLIER_ID);
    String selInvoiceId = pageContext.getParameter(HOLDTEL_SELECTED_INVOICE_ID);
    String selInvoiceNum = pageContext.getParameter(HOLDTEL_SELECTED_INVOICE_NUM);
    String selInvoiceHoldLine = pageContext.getParameter(HOLDTEL_SELECTED_INVOICE_HOLDLINE);
    String selMgrName = pageContext.getParameter(HOLDTEL_SELECTED_MANAGER_NAME);
    String selBuyerName = pageContext.getParameter(HOLDTEL_SELECTED_BUYER_NAME);
    String selSupplierName = pageContext.getParameter(HOLDTEL_SELECTED_SUPPLIER_NAME);
    String selSupplierSumOfInv = pageContext.getParameter(HOLDTEL_SEL_SUPPLIER_SUMOFINVOICE);
    String reportType = pageContext.getParameter(HOLDTEL_REPORT_TYPE);
   
    //add report type
    if(pageContext.getParameter("getReportButton") != null)
    {
      reportType = HOLDTEL_SUMMARY_REPORT;
      params.put(HOLDTEL_REPORT_TYPE, HOLDTEL_SUMMARY_REPORT);
      pageContext.putTransactionValue(HOLDTEL_REPORT_TYPE, HOLDTEL_SUMMARY_REPORT);
     
      pageContext.putTransactionValue(HOLDTEL_PURCHASE_GROUP, pGroup);
      pageContext.putTransactionValue(HOLDTEL_MANAGER_ID, mgrId);
      pageContext.putTransactionValue(HOLDTEL_MANAGER_NAME, mgrName);
      pageContext.putTransactionValue(HOLDTEL_BUYER_ID, buyerId);
      pageContext.putTransactionValue(HOLDTEL_BUYER_NAME, buyerName);
      pageContext.putTransactionValue(HOLDTEL_SUPPLIER_ID, supplierId);
      pageContext.putTransactionValue(HOLDTEL_SUPPLIER_NAME, supplierName);

     
      //clear Detail Report params
      pageContext.removeTransactionValue(HOLDTEL_DTL_BUYER_ID);
      pageContext.removeTransactionValue(HOLDTEL_DTL_BUYER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_DTL_SUPPLIER_ID);
      pageContext.removeTransactionValue(HOLDTEL_DTL_SUPPLIER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_INVOICE_NUM);
    }
    else if(pageContext.getParameter("getInvoicesButton") != null)
    {
      reportType = HOLDTEL_DETAIL_REPORT;
      params.put(HOLDTEL_REPORT_TYPE, HOLDTEL_DETAIL_REPORT);
      pageContext.putTransactionValue(HOLDTEL_REPORT_TYPE, HOLDTEL_DETAIL_REPORT);

      pageContext.putTransactionValue(HOLDTEL_DTL_BUYER_ID, dtlBuyerId);
      pageContext.putTransactionValue(HOLDTEL_DTL_BUYER_NAME, dtlBuyerName);
      pageContext.putTransactionValue(HOLDTEL_DTL_SUPPLIER_ID, dtlSupplierId);
      pageContext.putTransactionValue(HOLDTEL_DTL_SUPPLIER_NAME, dtlSupplierName);
      pageContext.putTransactionValue(HOLDTEL_INVOICE_NUM, invoiceNum);
     
      //clear summary report params
      pageContext.removeTransactionValue(HOLDTEL_PURCHASE_GROUP);
      pageContext.removeTransactionValue(HOLDTEL_MANAGER_ID);
      pageContext.removeTransactionValue(HOLDTEL_MANAGER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_BUYER_ID);
      pageContext.removeTransactionValue(HOLDTEL_BUYER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_SUPPLIER_ID);
      pageContext.removeTransactionValue(HOLDTEL_SUPPLIER_NAME);
    }
    else if(pageContext.getParameter("getExecReportButton") != null)
    {
      reportType = HOLDTEL_EXECUTIVE_REPORT;
      params.put(HOLDTEL_REPORT_TYPE, HOLDTEL_EXECUTIVE_REPORT);
      pageContext.putTransactionValue(HOLDTEL_REPORT_TYPE, HOLDTEL_EXECUTIVE_REPORT);

      //clear summary report params
      pageContext.removeTransactionValue(HOLDTEL_PURCHASE_GROUP);
      pageContext.removeTransactionValue(HOLDTEL_MANAGER_ID);
      pageContext.removeTransactionValue(HOLDTEL_MANAGER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_BUYER_ID);
      pageContext.removeTransactionValue(HOLDTEL_BUYER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_SUPPLIER_ID);
      pageContext.removeTransactionValue(HOLDTEL_SUPPLIER_NAME);
     
      //clear Detail Report params
      pageContext.removeTransactionValue(HOLDTEL_DTL_BUYER_ID);
      pageContext.removeTransactionValue(HOLDTEL_DTL_BUYER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_DTL_SUPPLIER_ID);
      pageContext.removeTransactionValue(HOLDTEL_DTL_SUPPLIER_NAME);
      pageContext.removeTransactionValue(HOLDTEL_INVOICE_NUM);
    }
    else
    {
      if(isEmpty(reportType))
        reportType = (String)pageContext.getTransactionValue(HOLDTEL_REPORT_TYPE);
      if(isEmpty(pGroup))
        pGroup = (String)pageContext.getTransactionValue(HOLDTEL_PURCHASE_GROUP);
      if(isEmpty(mgrId))
        mgrId = (String)pageContext.getTransactionValue(HOLDTEL_MANAGER_ID);
      if(isEmpty(mgrName))
        mgrName = (String)pageContext.getTransactionValue(HOLDTEL_MANAGER_NAME);
      if(isEmpty(buyerId))
        buyerId = (String)pageContext.getTransactionValue(HOLDTEL_BUYER_ID);
      if(isEmpty(buyerName))
        buyerName = (String)pageContext.getTransactionValue(HOLDTEL_BUYER_NAME);
      if(isEmpty(supplierId))
        supplierId = (String)pageContext.getTransactionValue(HOLDTEL_SUPPLIER_ID);
      if(isEmpty(supplierName))
        supplierName = (String)pageContext.getTransactionValue(HOLDTEL_SUPPLIER_NAME);
     
      if(isEmpty(dtlBuyerId))
        dtlBuyerId = (String)pageContext.getTransactionValue(HOLDTEL_DTL_BUYER_ID);
      if(isEmpty(dtlBuyerName))
        dtlBuyerName = (String)pageContext.getTransactionValue(HOLDTEL_DTL_BUYER_NAME);
      if(isEmpty(dtlSupplierId))
        dtlSupplierId = (String)pageContext.getTransactionValue(HOLDTEL_DTL_SUPPLIER_ID);
      if(isEmpty(dtlSupplierName))
        dtlSupplierName = (String)pageContext.getTransactionValue(HOLDTEL_DTL_SUPPLIER_NAME);
      if(isEmpty(invoiceNum))
        invoiceNum = (String)pageContext.getTransactionValue(HOLDTEL_INVOICE_NUM);
    }
     
    String event = pageContext.getParameter(EVENT_PARAM);
    if("HomeReturnLinkClick".equals(event))
    {
      selMgrName = null;
      selMgrId = null;
      selBuyerName = null;
      selBuyerId = null;
      selSupplierName = null;
      selSupplierId = null;
      selInvoiceNum = null;
      selInvoiceId = null;
      selInvoiceHoldLine = null;
    }
    if("ManagerReturnLinkClick".equals(event))
    {
      selMgrName = null;
      selMgrId = null;
      selBuyerName = null;
      selBuyerId = null;
      selSupplierName = null;
      selSupplierId = null;
      selInvoiceNum = null;
      selInvoiceId = null;
      selInvoiceHoldLine = null;
    }
    if("BuyerReturnLinkClick".equals(event))
    {
      selBuyerName = null;
      selBuyerId = null;
      selSupplierName = null;
      selSupplierId = null;
      selInvoiceNum = null;
      selInvoiceId = null;
      selInvoiceHoldLine = null;
    }
    if("SupplierReturnLinkClick".equals(event))
    {
      selSupplierName = null;
      selSupplierId = null;
      selInvoiceNum = null;
      selInvoiceId = null;
      selInvoiceHoldLine = null;
    }  
    if("InvoiceReturnLinkClick".equals(event))
    {
      selInvoiceNum = null;
      selInvoiceId = null;
      selInvoiceHoldLine = null;
    }
   
    if(pGroup != null && !"".equals(pGroup))
      params.put(HOLDTEL_PURCHASE_GROUP, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(pGroup));
    if(mgrId != null && !"".equals(mgrId))
      params.put(HOLDTEL_MANAGER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(mgrId));
    if(buyerId != null && !"".equals(buyerId))
      params.put(HOLDTEL_BUYER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(buyerId));
    if(supplierId != null && !"".equals(supplierId))
      params.put(HOLDTEL_SUPPLIER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(supplierId));
    if(dtlBuyerId != null && !"".equals(dtlBuyerId))
        params.put(HOLDTEL_DTL_BUYER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(dtlBuyerId));
    if(dtlSupplierId != null && !"".equals(dtlSupplierId))
        params.put(HOLDTEL_DTL_SUPPLIER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(dtlSupplierId));
    if(invoiceId != null && !"".equals(invoiceId))
      params.put(HOLDTEL_INVOICE_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(invoiceId));
    if(invoiceNum != null && !"".equals(invoiceNum))
      params.put(HOLDTEL_INVOICE_NUM, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(invoiceNum));
    if(mgrName != null && !"".equals(mgrName))
      params.put(HOLDTEL_MANAGER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(mgrName));
    if(buyerName != null && !"".equals(buyerName))
      params.put(HOLDTEL_BUYER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(buyerName));
    if(supplierName != null && !"".equals(supplierName))
      params.put(HOLDTEL_SUPPLIER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(supplierName));
    if(dtlBuyerName != null && !"".equals(dtlBuyerName))
        params.put(HOLDTEL_DTL_BUYER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(dtlBuyerName));
    if(dtlSupplierName != null && !"".equals(dtlSupplierName))
        params.put(HOLDTEL_DTL_SUPPLIER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(dtlSupplierName));
    if(selPGroup != null && !"".equals(selPGroup))
      params.put(HOLDTEL_SELECTED_PURCHASE_GROUP, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selPGroup));
    if(selMgrId != null && !"".equals(selMgrId))
      params.put(HOLDTEL_SELECTED_MANAGER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selMgrId));
    if(selBuyerId != null && !"".equals(selBuyerId))
      params.put(HOLDTEL_SELECTED_BUYER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selBuyerId));
    if(selSupplierId != null && !"".equals(selSupplierId))
      params.put(HOLDTEL_SELECTED_SUPPLIER_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selSupplierId));
    if(selInvoiceId != null && !"".equals(selInvoiceId))
      params.put(HOLDTEL_SELECTED_INVOICE_ID, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selInvoiceId));
    if(selInvoiceNum != null && !"".equals(selInvoiceNum))
      params.put(HOLDTEL_SELECTED_INVOICE_NUM, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selInvoiceNum));
    if(selInvoiceHoldLine != null && !"".equals(selInvoiceHoldLine))
      params.put(HOLDTEL_SELECTED_INVOICE_HOLDLINE, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selInvoiceHoldLine));
    if(selMgrName != null && !"".equals(selMgrName))
      params.put(HOLDTEL_SELECTED_MANAGER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selMgrName));
    if(selBuyerName != null && !"".equals(selBuyerName))
      params.put(HOLDTEL_SELECTED_BUYER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selBuyerName));
    if(selSupplierName != null && !"".equals(selSupplierName))
      params.put(HOLDTEL_SELECTED_SUPPLIER_NAME, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(selSupplierName));
    if(reportType != null && !"".equals(reportType))
      params.put(HOLDTEL_REPORT_TYPE, HOLDTEL_ENCRYPT_PARAM+pageContext.encrypt(reportType));
   
    if(selSupplierSumOfInv != null && !"".equals(selSupplierSumOfInv))
         pageContext.putTransactionValue(HOLDTEL_SEL_SUPPLIER_SUMOFINVOICE, selSupplierSumOfInv);
     
    return params;
  }

  protected void redirectPage(OAPageContext pageContext, String url, String functionName)
  {
    pageContext.forwardImmediately(url, functionName, KEEP_MENU_CONTEXT, null, getURLParams(pageContext), true, ADD_BREAD_CRUMB_YES);
  }
 
  private void hideItem(OAWebBean item)
  {
    if(item != null)
      item.setRendered(false);
  }

  protected boolean isEmpty(String value)
  {
    return (value == null || value.equals(""));
  }
 
  /**
   * procedure to set the link text to every page.
   * @param pageContext
   * @param webBean
   */
  protected void setReturnLinkText(OAPageContext pageContext,  OAWebBean webBean)
  {
    String managerName = pageContext.getParameter(HOLDTEL_SELECTED_MANAGER_NAME);
    String buyerName = pageContext.getParameter(HOLDTEL_SELECTED_BUYER_NAME);
    String supplierName = pageContext.getParameter(HOLDTEL_SELECTED_SUPPLIER_NAME);
    String invoiceHoldLineNum = pageContext.getParameter(HOLDTEL_SELECTED_INVOICE_HOLDLINE); //newly added
    if(!isEmpty(managerName))
    {
      OAMessageStyledTextBean mgrNameBean = (OAMessageStyledTextBean)webBean.findChildRecursive(HOLDTEL_MANAGER_RETURN_LINK_ID);
      if(mgrNameBean != null)
        mgrNameBean.setText(managerName);
    }
   
    if(!isEmpty(buyerName))
    {
      OAMessageStyledTextBean buyerNameBean = (OAMessageStyledTextBean)webBean.findChildRecursive(HOLDTEL_BUYER_RETURN_LINK_ID);
      if(buyerNameBean != null)
        buyerNameBean.setText(buyerName);
    }
   
    if(!isEmpty(supplierName))
    {
      OAMessageStyledTextBean SupplierNameBean = (OAMessageStyledTextBean)webBean.findChildRecursive(HOLDTEL_SUPPLIER_RETURN_LINK_ID);
      if(SupplierNameBean != null)
        SupplierNameBean.setText(supplierName);
    }
   
   
    if(!isEmpty(invoiceHoldLineNum))
    {
      OAMessageStyledTextBean InvoiceNameBean1 = (OAMessageStyledTextBean)webBean.findChildRecursive(HOLDTEL_INVOICE_RETURN_LINK_ID);
      if(InvoiceNameBean1 != null)
        InvoiceNameBean1.setText(invoiceHoldLineNum);
    }
  }
}

Dynamicllay adding Where Clause Condition to VO's

package cisco.oracle.apps.xxcfi.ap.holdtel.summary.server;

import com.sun.java.util.collections.ArrayList;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;


// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class xxcfiInvoicesSearchVOImpl extends OAViewObjectImpl
{
  public static final String RCS_ID="$Header: InvoicesSearchVOImpl.java 1.0 kandkuma$ ";
  public static final boolean RCS_ID_RECORDED =
  VersionInfo.recordClassVersion(RCS_ID, "cisco.oracle.apps.xxcfi.ap.holdtel.summary.server");
  /**This is the default constructor (do not remove)
   */
  public xxcfiInvoicesSearchVOImpl()
  {
  }

  /**
   * procedure to execute the invoice search vo.
   * @param purchaseGroup
   * @param managerId
   * @param buyerId
   * @param supplierId
   * @return
   */
  public Boolean execInvoiceSrchQuery(String purchaseGroup, String managerId, String buyerId, String supplierId)
    {
          setWhereClause(null);
          setWhereClauseParams(null);
       
          StringBuffer whereclause = new StringBuffer(400);
          ArrayList params = new ArrayList(4);
          int paramCount =7;
       
          params.add(managerId);
          params.add(buyerId);
          params.add(supplierId);
          params.add(managerId);
          params.add(buyerId);
          params.add(supplierId);
       
          if(purchaseGroup != null && !"".equals(purchaseGroup))
          {
            whereclause.append(" PURCHASE_GROUP = :");
            whereclause.append(paramCount++);
            params.add(purchaseGroup);
          }
       
          /*
          if(managerId !=null && !"".equals(managerId))
          {
              if(whereclause.toString().length()>1)
                  whereclause.append(" AND ");
                   
              whereclause.append(" MANAGER_ID = :");
              whereclause.append(paramCount++);
              params.add(managerId);
          }  
          if(buyerId != null && !"".equals(buyerId))
          {
              if (whereclause.toString().length() > 1)
                whereclause.append(" AND ");
     
              whereclause.append(" BUYER_ID = :");
              whereclause.append(paramCount++);
              params.add(buyerId);
          }
          if(supplierId != null && !"".equals(supplierId))
          {
                if(whereclause.toString().length()>1)
                  whereclause.append(" AND ");
                   
                whereclause.append(" SUPPLIER_ID = :");
                whereclause.append(paramCount++);
                params.add(supplierId);
          }
          */
          if( whereclause.toString().length() > 1)
              setWhereClause(whereclause.toString());

          setWhereClauseParams(params.toArray());
       
          executeQuery();
       
          if(first()!=null)
              return Boolean.TRUE;
           
          return Boolean.FALSE;
    }
}

Calling Page from AM's

package cisco.oracle.apps.xxcfi.ap.holdtel.summary.server;

import cisco.oracle.apps.xxcfi.ap.holdtel.server.xxcfiHoldtelAMImpl;
import oracle.apps.fnd.common.VersionInfo;
//import cisco.oracle.apps.xxcfi.ap.holdtel.summary.server.xxcfiBuyerSearchVOImpl;
//import cisco.oracle.apps.xxcfi.ap.holdtel.summary.server.xxcfiManagerSearchVOImpl;
//import cisco.oracle.apps.xxcfi.ap.holdtel.summary.server.xxcfiSupplierSearchVOImpl;
//import cisco.oracle.apps.xxcfi.ap.holdtel.summary.server.xxcfiInvoicesSearchVOImpl;
//import cisco.oracle.apps.xxcfi.ap.holdtel.summary.server.xxcfiInvoicesDtlsSearchVOImpl;


// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class xxcfiSummaryReportsAMImpl extends xxcfiHoldtelAMImpl
{
  public static final String RCS_ID="$Header: SummaryReportsAMImpl.java 1.0 kandkuma $ ";
  public static final boolean RCS_ID_RECORDED =
  VersionInfo.recordClassVersion(RCS_ID, "cisco.oracle.apps.xxcfi.ap.holdtel.summary.server");

  /**This is the default constructor (do not remove)
   */
  public xxcfiSummaryReportsAMImpl()
  {
  }

  /**
   * procedure to call the manager search query
   * @param purchasingGroup
   * @param managerId
   * @param buyerId
   * @param supplierId
   */
  public void execManagerSrchQuery(String purchasingGroup, String managerId, String buyerId, String supplierId)
  {
    xxcfiManagerSearchVOImpl mgrSrchVO = getxxcfiManagerSearchVO1();
    mgrSrchVO.execManagerSrchQuery(purchasingGroup,  managerId, buyerId, supplierId); //calls the manager search vo.  
  }
 
 /**
   * procedure to call the buyer search query
   * @param purchaseGroup
   * @param managerId
   * @param buyerId
   * @param supplierId
 */
   public void execBuyerSrchQuery(String purchaseGroup, String managerId, String buyerId, String supplierId)
   {
     xxcfiBuyerSearchVOImpl buyerSrchVO = getxxcfiBuyerSearchVO1();
     buyerSrchVO.execBuyerSrchQuery(purchaseGroup,managerId,buyerId,supplierId); // executes the buyer search vo.
   }
 
 /**
   * procedure to call the supplier search query
   * @param purchaseGroup
   * @param managerId
   * @param buyerId
   * @param supplierId
 */
   public void execSupplierSrchQuery(String purchaseGroup, String managerId, String buyerId, String supplierId)
   {
     xxcfiSupplierSearchVOImpl supplierSrchVO = getxxcfiSupplierSearchVO1();  
     supplierSrchVO.execSupplierSrchQuery(purchaseGroup,managerId,buyerId,supplierId); //calls the supplier search vo.
   }
 /**
  * procedure to call the inovice search query
  * @param purchaseGroup
  * @param managerId
  * @param buyerId
  * @param supplierId
 */

  public void execInvoiceSrchQuery(String purchaseGroup, String managerId, String buyerId, String supplierId)
  {
  xxcfiInvoicesSearchVOImpl invoiceSrchVO = getxxcfiInvoicesSearchVO1();
  invoiceSrchVO.execInvoiceSrchQuery(purchaseGroup,managerId,buyerId,supplierId); // executes the invoice search vo.
  }
 
  /**
   * procedure to calll the invoice details search query.
   * @param buyerId
   * @param supplierId
   * @param invoiceId
   */
  public void execInvoiceDetailSrchQuery(String buyerId, String supplierId, String invoiceId)
  {
    xxcfiInvoicesDtlsSearchVOImpl invoiceDetailsSrchVO = getxxcfiInvoicesDtlsSearchVO1();
    invoiceDetailsSrchVO.execInvoiceDetailSrchQuery(buyerId,supplierId,invoiceId); // calls the invoice details search vo.
  }


  /**Container's getter for xxcfiBuyerSearchVO1
   */
  public xxcfiBuyerSearchVOImpl getxxcfiBuyerSearchVO1()
  {
    return (xxcfiBuyerSearchVOImpl)findViewObject("xxcfiBuyerSearchVO1");
  }


  /**Container's getter for xxcfiInvoicesSearchVO1
   */
  public xxcfiInvoicesSearchVOImpl getxxcfiInvoicesSearchVO1()
  {
    return (xxcfiInvoicesSearchVOImpl)findViewObject("xxcfiInvoicesSearchVO1");
  }

  /**Container's getter for xxcfiManagerSearchVO1
   */
  public xxcfiManagerSearchVOImpl getxxcfiManagerSearchVO1()
  {
    return (xxcfiManagerSearchVOImpl)findViewObject("xxcfiManagerSearchVO1");
  }


  /**Container's getter for xxcfiSupplierSearchVO1
   */
  public xxcfiSupplierSearchVOImpl getxxcfiSupplierSearchVO1()
  {
    return (xxcfiSupplierSearchVOImpl)findViewObject("xxcfiSupplierSearchVO1");
  }

  /**Container's getter for xxcfiInvoicesDtlsSearchVO1
   */
  public xxcfiInvoicesDtlsSearchVOImpl getxxcfiInvoicesDtlsSearchVO1()
  {
    return (xxcfiInvoicesDtlsSearchVOImpl)findViewObject("xxcfiInvoicesDtlsSearchVO1");
  }

  /**Sample main for debugging Business Components code using the tester.
   */
  public static void main(String[] args)
  {
    launchTester("cisco.oracle.apps.xxcfi.ap.holdtel.summary.server", /* package name */
      "xxcfiSummaryReportsAMLocal" /* Configuration Name */);
  }
}

Submitting Concurrent Programs through OAF Page

package oracle.apps.cfi.ipr.server.webui;

import com.sun.java.util.collections.HashMap;

import java.sql.Connection;

import java.util.Hashtable;
import java.util.Vector;

import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * Controller for ...
 */
public class orderDetailCO extends OAControllerImpl
{
  public static final String RCS_ID =
    "$Header:   /apps/pvcs/archive/sj/xxcfi/11.5.0/java/mds/oracle/apps/cfi/ipr/server/webui/orderDetailCO.java_v   1.2   11 Nov 2004 12:31:16   tvatsa  $";
  public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    // Profile
    boolean isGlobal = false;
    String operatingProfile = pageContext.getProfile("ORG_ID");
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    // Responsibility
    int respId = pageContext.getResponsibilityId();
    String respName = pageContext.getResponsibilityName();

    // User
    int userId = pageContext.getUserId();
    String userName = pageContext.getUserName();

    // Org Id
    int orgId = pageContext.getOrgId(); //165;
    String srtOrgId = new String().valueOf(orgId);


    // Get a Handle to the OU PopList
    OAMessageChoiceBean operUnitPopList =
      (OAMessageChoiceBean)webBean.findIndexedChildRecursive("operatingUnit");

    if (!isGlobal)
    {
      operUnitPopList.setDefaultValue(srtOrgId);
      operUnitPopList.setDisabled(true);
    } else
    {
      operUnitPopList.setDefaultValue(null);
      operUnitPopList.setDisabled(false);
    }

    // Get a Handle to the Preparer
    OAMessageLovInputBean preparerLOV =
      (OAMessageLovInputBean)webBean.findIndexedChildRecursive("preparerEmail");

    if (!isGlobal)
    {
      //int i = 9;
      //preparerLOV.setDefaultValue("bmcmanus");
      preparerLOV.setRendered(false);
      //preparerLOV.setDisabled(true);

    } else
    {
      preparerLOV.setRendered(true);
    }
 
    if(pageContext.getParameter("apPoSplitConfirmOk")!=null)
    {
      HashMap hm = new HashMap();
      String url = "OA.jsp?akRegionCode=FNDCPREQUESTVIEWPAGE&akRegionApplicationId=0";
      // Show breadcrumbs
      pageContext.setForwardURL(url, null,
                                OAWebBeanConstants.KEEP_MENU_CONTEXT, null,
                                hm, true,
                                OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
                                OAWebBeanConstants.IGNORE_MESSAGES);
    }

  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);

    // Profile
    boolean isGlobal = false;
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    if (pageContext.getParameter("webButton") != null)
    {

      String operatingUnit = new String();
      if (isGlobal)
      {
        operatingUnit = pageContext.getParameter("operatingUnit");
      } else if (!isGlobal)
      {
        int orgId = pageContext.getOrgId();
        String srtOrgId = new String().valueOf(orgId);
        operatingUnit = srtOrgId;
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");

      String preparerEmail = new String();
      if (isGlobal)
      {
        preparerEmail = pageContext.getParameter("preparerEmail");
      } else if (!isGlobal)
      {
        int userId = pageContext.getUserId();
        String userName = pageContext.getUserName();
        preparerEmail = userName; //"bmcmanus";
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");
      String reqStatus = pageContext.getParameter("orderStatus");
      String currency = pageContext.getParameter("currency");
      String department = pageContext.getParameter("department");
      String account = pageContext.getParameter("account");
      String supplier = pageContext.getParameter("supplier");
      //String preparerEmail = pageContext.getParameter("preparerEmail");
      String requesterEmail = pageContext.getParameter("requesterEmail");
      //String deliverEmail = pageContext.getParameter("deliverEmail");
      String dateTo = pageContext.getParameter("dateTo");
      String dateFrom = pageContext.getParameter("dateFrom");
      String supplierSite = pageContext.getParameter("location");
      //String preparerId = pageContext.getParameter("PreparerId");
      SimpleDateFormat dateFormat1;
      Date d1;
      Date d2;
      String dfrom=null;
      String dto=null;
      try
      {
        dateFormat1 = new SimpleDateFormat("YYYY/MM/DD");
        d1 = dateFormat1.parse(dateFrom);
        d2 = dateFormat1.parse(dateTo);
        dfrom = dateFormat1.format(d1);
        dto = dateFormat1.format(d2);
      }
      catch(Exception e)
      {
        //System.out.println(e);
        ;
      }
      Vector concParams = new Vector();
   
      concParams.add(operatingUnit);
      concParams.add(requesterEmail);
      concParams.add(reqStatus);
      concParams.add(currency);
      concParams.add(supplier);
      concParams.add(supplierSite);
      concParams.add(department);
      concParams.add(account);
     // concParams.add(dateFrom);    
    //  concParams.add(dateTo);
      concParams.add(dfrom);
      concParams.add(dto);
   
      submitConcProgram(pageContext, concParams);
    }
  }

  private void submitConcProgram(OAPageContext pageContext, Vector concParams)
  {
    OADBTransaction txn = pageContext.getRootApplicationModule().getOADBTransaction();
 
    Connection conn = txn.getJdbcConnection();
    try
    {
      String cpAppName = "XXCPO";
      String cpName = "XXCFIORDDET";
      String cpDesc = "";
      ConcurrentRequest cr = new ConcurrentRequest(conn);
      int requestId =
      cr.submitRequest(cpAppName, cpName, cpDesc, null, false, concParams);
      txn.commit();
      if (requestId != 0)
      {
        pageContext.redirectToDialogPage(getWarningDialog(pageContext,requestId));
      }
    }
    catch (Exception e)
    {
      ;
    }
  }

  public OADialogPage getWarningDialog(OAPageContext pageContext,int requestId)
  {

    String reportName = null;
    OAHeaderBean hdrReportName = (OAHeaderBean)pageContext.getPageLayoutBean().findIndexedChildRecursive("headerRN");
    if(hdrReportName != null)
      reportName = hdrReportName.getText();
    MessageToken[] tokens = { new MessageToken("REPORT_NAME", reportName),
                              new MessageToken("REQUEST_ID", String.valueOf(requestId))
                            };
    OAException message = new OAException("ICX", "XXCFI_SHOW_REQUEST_ID", tokens, OAException.INFORMATION, null);
    OADialogPage warningDialog = new OADialogPage(OAException.CONFIRMATION, message, null, "", "");
    //String okButtonLabel = pageContext.getMessage("FND", "OK", null);
    warningDialog.setRetainAMValue(true);
    warningDialog.setOkButtonItemName("apPoSplitConfirmOk");
    //warningDialog.setOkButtonLabel(okButtonLabel);
     warningDialog.setOkButtonLabel("OK");
    warningDialog.setNoButtonUrl(null);
    warningDialog.setOkButtonToPost(true);
    warningDialog.setPostToCallingPage(true);
    Hashtable formParams = new Hashtable(1);
    formParams.put("isFromWarningDialog", "Y");
    warningDialog.setFormParameters(formParams);
    return warningDialog;
  }
}

Submitting Concurrent Programs through OAF Page

/*===========================================================================+
 |   Copyright (c) 2001, 2003 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package oracle.apps.cfi.ipr.server.webui;

import com.sun.java.util.collections.HashMap;

import java.sql.Connection;

import java.util.Hashtable;
import java.util.Vector;

import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * Controller for ...
 */
public class orderDetailCO extends OAControllerImpl
{
  public static final String RCS_ID =
    "$Header:   /apps/pvcs/archive/sj/xxcfi/11.5.0/java/mds/oracle/apps/cfi/ipr/server/webui/orderDetailCO.java_v   1.2   11 Nov 2004 12:31:16   tvatsa  $";
  public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    // Profile
    boolean isGlobal = false;
    String operatingProfile = pageContext.getProfile("ORG_ID");
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    // Responsibility
    int respId = pageContext.getResponsibilityId();
    String respName = pageContext.getResponsibilityName();

    // User
    int userId = pageContext.getUserId();
    String userName = pageContext.getUserName();

    // Org Id
    int orgId = pageContext.getOrgId(); //165;
    String srtOrgId = new String().valueOf(orgId);


    // Get a Handle to the OU PopList
    OAMessageChoiceBean operUnitPopList =
      (OAMessageChoiceBean)webBean.findIndexedChildRecursive("operatingUnit");

    if (!isGlobal)
    {
      operUnitPopList.setDefaultValue(srtOrgId);
      operUnitPopList.setDisabled(true);
    } else
    {
      operUnitPopList.setDefaultValue(null);
      operUnitPopList.setDisabled(false);
    }

    // Get a Handle to the Preparer
    OAMessageLovInputBean preparerLOV =
      (OAMessageLovInputBean)webBean.findIndexedChildRecursive("preparerEmail");

    if (!isGlobal)
    {
      //int i = 9;
      //preparerLOV.setDefaultValue("bmcmanus");
      preparerLOV.setRendered(false);
      //preparerLOV.setDisabled(true);

    } else
    {
      preparerLOV.setRendered(true);
    }
   
    if(pageContext.getParameter("apPoSplitConfirmOk")!=null)
    {
      HashMap hm = new HashMap();
      String url = "OA.jsp?akRegionCode=FNDCPREQUESTVIEWPAGE&akRegionApplicationId=0";
      // Show breadcrumbs
      pageContext.setForwardURL(url, null,
                                OAWebBeanConstants.KEEP_MENU_CONTEXT, null,
                                hm, true,
                                OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
                                OAWebBeanConstants.IGNORE_MESSAGES);
    }

  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);

    // Profile
    boolean isGlobal = false;
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    if (pageContext.getParameter("webButton") != null)
    {

      String operatingUnit = new String();
      if (isGlobal)
      {
        operatingUnit = pageContext.getParameter("operatingUnit");
      } else if (!isGlobal)
      {
        int orgId = pageContext.getOrgId();
        String srtOrgId = new String().valueOf(orgId);
        operatingUnit = srtOrgId;
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");

      String preparerEmail = new String();
      if (isGlobal)
      {
        preparerEmail = pageContext.getParameter("preparerEmail");
      } else if (!isGlobal)
      {
        int userId = pageContext.getUserId();
        String userName = pageContext.getUserName();
        preparerEmail = userName; //"bmcmanus";
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");
      String reqStatus = pageContext.getParameter("orderStatus");
      String currency = pageContext.getParameter("currency");
      String department = pageContext.getParameter("department");
      String account = pageContext.getParameter("account");
      String supplier = pageContext.getParameter("supplier");
      //String preparerEmail = pageContext.getParameter("preparerEmail");
      String requesterEmail = pageContext.getParameter("requesterEmail");
      //String deliverEmail = pageContext.getParameter("deliverEmail");
      String dateTo = pageContext.getParameter("dateTo");
      String dateFrom = pageContext.getParameter("dateFrom");
      String supplierSite = pageContext.getParameter("location");
      //String preparerId = pageContext.getParameter("PreparerId");
      SimpleDateFormat dateFormat1;  
      Date d1;
      Date d2;
      String dfrom=null;
      String dto=null;
      try
      {
        dateFormat1 = new SimpleDateFormat("YYYY/MM/DD");
        d1 = dateFormat1.parse(dateFrom);
        d2 = dateFormat1.parse(dateTo);
        dfrom = dateFormat1.format(d1);
        dto = dateFormat1.format(d2);
      }
      catch(Exception e)
      {
        //System.out.println(e);
        ;
      }
      Vector concParams = new Vector();
     
      concParams.add(operatingUnit);
      concParams.add(requesterEmail);
      concParams.add(reqStatus);
      concParams.add(currency);
      concParams.add(supplier);
      concParams.add(supplierSite);
      concParams.add(department);
      concParams.add(account);
     // concParams.add(dateFrom);    
    //  concParams.add(dateTo);
      concParams.add(dfrom);
      concParams.add(dto);
   
      submitConcProgram(pageContext, concParams);
    }
  }

  private void submitConcProgram(OAPageContext pageContext, Vector concParams)
  {
    OADBTransaction txn = pageContext.getRootApplicationModule().getOADBTransaction();
   
    Connection conn = txn.getJdbcConnection();
    try
    {
      String cpAppName = "XXCPO";
      String cpName = "XXCFIORDDET";
      String cpDesc = "";
      ConcurrentRequest cr = new ConcurrentRequest(conn);
      int requestId =
      cr.submitRequest(cpAppName, cpName, cpDesc, null, false, concParams);
      txn.commit();
      if (requestId != 0)
      {
        pageContext.redirectToDialogPage(getWarningDialog(pageContext,requestId));
      }
    }
    catch (Exception e)
    {
      ;
    }
  }
 
  public OADialogPage getWarningDialog(OAPageContext pageContext,int requestId)
  {
 
    String reportName = null;
    OAHeaderBean hdrReportName = (OAHeaderBean)pageContext.getPageLayoutBean().findIndexedChildRecursive("headerRN");
    if(hdrReportName != null)
      reportName = hdrReportName.getText();
    MessageToken[] tokens = { new MessageToken("REPORT_NAME", reportName),
                              new MessageToken("REQUEST_ID", String.valueOf(requestId))
                            };
    OAException message = new OAException("ICX", "XXCFI_SHOW_REQUEST_ID", tokens, OAException.INFORMATION, null);
    OADialogPage warningDialog = new OADialogPage(OAException.CONFIRMATION, message, null, "", "");
    //String okButtonLabel = pageContext.getMessage("FND", "OK", null);
    warningDialog.setRetainAMValue(true);
    warningDialog.setOkButtonItemName("apPoSplitConfirmOk");
    //warningDialog.setOkButtonLabel(okButtonLabel);
     warningDialog.setOkButtonLabel("OK");
    warningDialog.setNoButtonUrl(null);
    warningDialog.setOkButtonToPost(true);
    warningDialog.setPostToCallingPage(true);
    Hashtable formParams = new Hashtable(1);
    formParams.put("isFromWarningDialog", "Y");
    warningDialog.setFormParameters(formParams);
    return warningDialog;
  }
}

Submitting Concurrent Programs through OAF Page

/*===========================================================================+
 |   Copyright (c) 2001, 2003 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package oracle.apps.cfi.ipr.server.webui;

import com.sun.java.util.collections.HashMap;

import java.sql.Connection;

import java.util.Hashtable;
import java.util.Vector;

import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;

import java.util.Date;
import java.text.SimpleDateFormat;

/**
 * Controller for ...
 */
public class orderDetailCO extends OAControllerImpl
{
  public static final String RCS_ID =
    "$Header:   /apps/pvcs/archive/sj/xxcfi/11.5.0/java/mds/oracle/apps/cfi/ipr/server/webui/orderDetailCO.java_v   1.2   11 Nov 2004 12:31:16   tvatsa  $";
  public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    // Profile
    boolean isGlobal = false;
    String operatingProfile = pageContext.getProfile("ORG_ID");
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    // Responsibility
    int respId = pageContext.getResponsibilityId();
    String respName = pageContext.getResponsibilityName();

    // User
    int userId = pageContext.getUserId();
    String userName = pageContext.getUserName();

    // Org Id
    int orgId = pageContext.getOrgId(); //165;
    String srtOrgId = new String().valueOf(orgId);


    // Get a Handle to the OU PopList
    OAMessageChoiceBean operUnitPopList =
      (OAMessageChoiceBean)webBean.findIndexedChildRecursive("operatingUnit");

    if (!isGlobal)
    {
      operUnitPopList.setDefaultValue(srtOrgId);
      operUnitPopList.setDisabled(true);
    } else
    {
      operUnitPopList.setDefaultValue(null);
      operUnitPopList.setDisabled(false);
    }

    // Get a Handle to the Preparer
    OAMessageLovInputBean preparerLOV =
      (OAMessageLovInputBean)webBean.findIndexedChildRecursive("preparerEmail");

    if (!isGlobal)
    {
      //int i = 9;
      //preparerLOV.setDefaultValue("bmcmanus");
      preparerLOV.setRendered(false);
      //preparerLOV.setDisabled(true);

    } else
    {
      preparerLOV.setRendered(true);
    }
   
    if(pageContext.getParameter("apPoSplitConfirmOk")!=null)
    {
      HashMap hm = new HashMap();
      String url = "OA.jsp?akRegionCode=FNDCPREQUESTVIEWPAGE&akRegionApplicationId=0";
      // Show breadcrumbs
      pageContext.setForwardURL(url, null,
                                OAWebBeanConstants.KEEP_MENU_CONTEXT, null,
                                hm, true,
                                OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
                                OAWebBeanConstants.IGNORE_MESSAGES);
    }

  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);

    // Profile
    boolean isGlobal = false;
    String queryAllProfile =
      pageContext.getProfile("XXCFI_IPROC_REPORT_QRY_ALL");
    if (queryAllProfile == null)
    {
      queryAllProfile = new String("N");
    }

    if (queryAllProfile.equalsIgnoreCase("Y"))
    {
      isGlobal = true;
    }


    if (pageContext.getParameter("webButton") != null)
    {

      String operatingUnit = new String();
      if (isGlobal)
      {
        operatingUnit = pageContext.getParameter("operatingUnit");
      } else if (!isGlobal)
      {
        int orgId = pageContext.getOrgId();
        String srtOrgId = new String().valueOf(orgId);
        operatingUnit = srtOrgId;
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");

      String preparerEmail = new String();
      if (isGlobal)
      {
        preparerEmail = pageContext.getParameter("preparerEmail");
      } else if (!isGlobal)
      {
        int userId = pageContext.getUserId();
        String userName = pageContext.getUserName();
        preparerEmail = userName; //"bmcmanus";
      }

      //String operatingUnit = pageContext.getParameter("operatingUnit");
      String reqStatus = pageContext.getParameter("orderStatus");
      String currency = pageContext.getParameter("currency");
      String department = pageContext.getParameter("department");
      String account = pageContext.getParameter("account");
      String supplier = pageContext.getParameter("supplier");
      //String preparerEmail = pageContext.getParameter("preparerEmail");
      String requesterEmail = pageContext.getParameter("requesterEmail");
      //String deliverEmail = pageContext.getParameter("deliverEmail");
      String dateTo = pageContext.getParameter("dateTo");
      String dateFrom = pageContext.getParameter("dateFrom");
      String supplierSite = pageContext.getParameter("location");
      //String preparerId = pageContext.getParameter("PreparerId");
      SimpleDateFormat dateFormat1;  
      Date d1;
      Date d2;
      String dfrom=null;
      String dto=null;
      try
      {
        dateFormat1 = new SimpleDateFormat("YYYY/MM/DD");
        d1 = dateFormat1.parse(dateFrom);
        d2 = dateFormat1.parse(dateTo);
        dfrom = dateFormat1.format(d1);
        dto = dateFormat1.format(d2);
      }
      catch(Exception e)
      {
        //System.out.println(e);
        ;
      }
      Vector concParams = new Vector();
     
      concParams.add(operatingUnit);
      concParams.add(requesterEmail);
      concParams.add(reqStatus);
      concParams.add(currency);
      concParams.add(supplier);
      concParams.add(supplierSite);
      concParams.add(department);
      concParams.add(account);
     // concParams.add(dateFrom);    
    //  concParams.add(dateTo);
      concParams.add(dfrom);
      concParams.add(dto);
   
      submitConcProgram(pageContext, concParams);
    }
  }

  private void submitConcProgram(OAPageContext pageContext, Vector concParams)
  {
    OADBTransaction txn = pageContext.getRootApplicationModule().getOADBTransaction();
   
    Connection conn = txn.getJdbcConnection();
    try
    {
      String cpAppName = "XXCPO";
      String cpName = "XXCFIORDDET";
      String cpDesc = "";
      ConcurrentRequest cr = new ConcurrentRequest(conn);
      int requestId =
      cr.submitRequest(cpAppName, cpName, cpDesc, null, false, concParams);
      txn.commit();
      if (requestId != 0)
      {
        pageContext.redirectToDialogPage(getWarningDialog(pageContext,requestId));
      }
    }
    catch (Exception e)
    {
      ;
    }
  }
 
  public OADialogPage getWarningDialog(OAPageContext pageContext,int requestId)
  {
 
    String reportName = null;
    OAHeaderBean hdrReportName = (OAHeaderBean)pageContext.getPageLayoutBean().findIndexedChildRecursive("headerRN");
    if(hdrReportName != null)
      reportName = hdrReportName.getText();
    MessageToken[] tokens = { new MessageToken("REPORT_NAME", reportName),
                              new MessageToken("REQUEST_ID", String.valueOf(requestId))
                            };
    OAException message = new OAException("ICX", "XXCFI_SHOW_REQUEST_ID", tokens, OAException.INFORMATION, null);
    OADialogPage warningDialog = new OADialogPage(OAException.CONFIRMATION, message, null, "", "");
    //String okButtonLabel = pageContext.getMessage("FND", "OK", null);
    warningDialog.setRetainAMValue(true);
    warningDialog.setOkButtonItemName("apPoSplitConfirmOk");
    //warningDialog.setOkButtonLabel(okButtonLabel);
     warningDialog.setOkButtonLabel("OK");
    warningDialog.setNoButtonUrl(null);
    warningDialog.setOkButtonToPost(true);
    warningDialog.setPostToCallingPage(true);
    Hashtable formParams = new Hashtable(1);
    formParams.put("isFromWarningDialog", "Y");
    warningDialog.setFormParameters(formParams);
    return warningDialog;
  }
}

OAF Date Convertion, Typed in Java and OAF

import java.util.*;
import java.text.*;
public class StringToDate {
   public static void main(String[] args)
{
 try
{   
String str_date="11-June-07";
         DateFormat formatter ;
     Date date ;
          formatter = new SimpleDateFormat("dd-MMM-yy");
              date = (Date)formatter.parse(str_date);   
               System.out.println("Today is " +date );
    } catch (ParseException e)
    {System.out.println("Exception :"+e);    }   
    
   }
}
------------------------

import java.text.SimpleDateFormat;
import java.text.DateFormat;
import oracle.jbo.domain.Date;

Date convertedDate = am.getOADBTransaction().getCurrentUserDate();//new Date();
String convertedDateString;
java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("MM/dd/yyyy");
convertedDateString = displayDateFormat.format(convertedDate.dateValue());
-----------------------------------------------

OAViewObject vo = (OAviewObject) getVo1();
row = vo.getCurrentRow();
Date value = row.getAttribute("Nameof the Date Attribute");

OADBTransaction transaction = getOADBTransaction();
long sysdate = transaction.getCurrentDBDate().dateValue().getTime();
long startDate = value.dateValue().getTime();//value is fetched in above code
if (startDate < sysdate)
{
    //Put your Logic here
}

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

   1.
      /*
   2.
        Convert date string from one format to another format using SimpleDateFormat
   3.
        This example shows how to convert format of a string containing date
   4.
        and time to other formats using Java SimpleDateFormat class.
   5.
      */
   6.
      
   7.
      import java.util.Date;
   8.
      import java.text.ParseException;
   9.
      import java.text.SimpleDateFormat;
  10.
      
  11.
      public class ConvertDateFormats {
  12.
      
  13.
      public static void main(String[] args) {
  14.
      
  15.
      //string containing date in one format
  16.
      String strDate = "12/12/07";
  17.
      
  18.
      try
  19.
      {
  20.
      //create SimpleDateFormat object with source string date format
  21.
      SimpleDateFormat sdfSource = new SimpleDateFormat("dd/MM/yy");
  22.
      
  23.
      //parse the string into Date object
  24.
      Date date = sdfSource.parse(strDate);
  25.
      
  26.
      //create SimpleDateFormat object with desired date format
  27.
      SimpleDateFormat sdfDestination = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
  28.
      
  29.
      //parse the date into another format
  30.
      strDate = sdfDestination.format(date);
  31.
      
  32.
      System.out.println("Date is converted from dd/MM/yy format to MM-dd-yyyy hh:mm:ss");
  33.
      System.out.println("Converted date is : " + strDate);
  34.
      
  35.
      }
  36.
      catch(ParseException pe)
  37.
      {
  38.
      System.out.println("Parse Exception : " + pe);
  39.
      }
  40.
      }
  41.
      }
  42.
      
  43.
      /*
  44.
      Typical output would be
  45.
      Date is converted from dd/MM/yy format to MM-dd-yyyy hh:mm:ss
  46.
      Converted date is : 12-12-2007 12:00:00
  47.
      */

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

# Date date = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("StartDate"); 
# Date edate = (Date)oaapplicationmodule.findViewObject("AddNewAssignmentVO").first().getAttribute("EndDate"); 
#  
#  
# if (date != null && edate != null) 
#                        { 
#                         String Xs11 = oapagecontext.getOANLSServices().dateToString(date); 
#                         String Xs12 = oapagecontext.getOANLSServices().dateToString(edate); 
# }
-----------------

13-Jul-2010

Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String today = dateFormat.format(calendar.getTime());

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

package oracle.apps.xxper.selfservice.appraisals.webui;

import com.sun.java.util.collections.HashMap;
import java.io.Serializable;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.*;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageCheckBoxBean;
import oracle.apps.per.selfservice.appraisals.ApprConstants;
import oracle.apps.per.selfservice.arch.webui.PerOAControllerImpl;
import oracle.apps.per.selfservice.common.webui.CommonCO;
import oracle.apps.per.selfservice.compgaps.Constants;
import oracle.apps.per.selfservice.appraisals.webui.MAFinalRatingsPageCO;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.OAViewObject;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean;
import oracle.apps.per.selfservice.appraisals.server.AppraisalVORowImpl;

public class XXPERMAFinalRatingsPageCO extends MAFinalRatingsPageCO
{
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
writeLog("XXPER",pageContext,"Start PR XXPERMAFinalRatingsPageCO ");
OAMessageDateFieldBean dateBean =(OAMessageDateFieldBean) webBean.findChildRecursive("DeliveryDateTime");
if(dateBean !=null )
{
String dateBeanValue = (String) dateBean.getValue(pageContext) ;
writeLog("XXPER",pageContext,"dateBean Value "+dateBeanValue);
if(dateBeanValue !=null)
{
if(dateBeanValue.indexOf(".0") !=-1)
dateBeanValue = dateBeanValue.substring(0,dateBeanValue.length()-2);
writeLog("XXPER",pageContext,"dateBean Updated Value "+dateBeanValue);

String dateMaskQry = "SELECT value FROM V$NLS_Parameters WHERE parameter ='NLS_DATE_FORMAT'";
writeLog("XXPER",pageContext,"dateMaskQry "+dateMaskQry);
String dateMask = (String) executeSql(dateMaskQry, pageContext, webBean);
writeLog("XXPER",pageContext,"dateMask : "+dateMask);
String dateConvertQry = "select to_char(fnd_date.canonical_to_date('"dateBeanValue"') ,'"dateMask" HH24:MI:SS') from dual";
writeLog("XXPER",pageContext,"dateConvertQry "+dateConvertQry);
String convertedDateValue = (String) executeSql(dateConvertQry,pageContext,webBean);
writeLog("XXPER",pageContext,"convertedDateValue "+convertedDateValue);
if(convertedDateValue == null )
convertedDateValue = dateBeanValue;
dateBean.setValue(pageContext,convertedDateValue);
writeLog("XXPER",pageContext,"After set the value "+convertedDateValue);
setAttribute3(pageContext, convertedDateValue);
writeLog("XXPER",pageContext,"After set the VO value "+convertedDateValue);
}else
{
writeLog("XXPER",pageContext,"dateBean value is null from the bean Get the value from getAttribute3() method");
dateBeanValue = getAttribute3(pageContext);
dateBean.setValue(pageContext,dateBeanValue);
}
}else
{
writeLog("XXPER",pageContext,"dateBean is null ");
}

writeLog("XXPER",pageContext,"End PR XXPERMAFinalRatingsPageCO ");
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{

writeLog("XXPER",pageContext,"Start PFR XXPERMAFinalRatingsPageCO ");
writeLog("XXPER",pageContext,"Event Param "+pageContext.getParameter(EVENT_PARAM));
OAMessageDateFieldBean dateBean =(OAMessageDateFieldBean) webBean.findChildRecursive("DeliveryDateTime");
if(dateBean !=null )
{
String dateBeanValue = (String) dateBean.getValue(pageContext) ;
if(dateBeanValue !=null)
{
if(dateBeanValue.indexOf(".0") !=-1)
dateBeanValue = dateBeanValue.substring(0,dateBeanValue.length()-2);
writeLog("XXPER",pageContext,"dateBean Updated Value "+dateBeanValue);

String dateMaskQry = "SELECT value FROM V$NLS_Parameters WHERE parameter ='NLS_DATE_FORMAT'";
writeLog("XXPER",pageContext,"dateMaskQry "+dateMaskQry);
String dateMask = (String) executeSql(dateMaskQry, pageContext, webBean);
writeLog("XXPER",pageContext,"dateMask : "+dateMask);
String dateConvertQry = "select to_char(fnd_date.canonical_to_date('"dateBeanValue"') ,'"dateMask" HH24:MI:SS') from dual";
//String dateConvertQry = "select fnd_date.string_to_canonical('"dateBeanValue"','"dateMask" HH24:MI:SS') from dual";

writeLog("XXPER",pageContext,"dateConvertQry "+dateConvertQry);
String convertedDateValue = (String) executeSql(dateConvertQry,pageContext,webBean);
writeLog("XXPER",pageContext,"convertedDateValue "+convertedDateValue);
if(convertedDateValue == null )
convertedDateValue = dateBeanValue;

dateBean.setValue(pageContext,convertedDateValue);
writeLog("XXPER",pageContext,"After set the value "+convertedDateValue);
setAttribute3(pageContext, convertedDateValue);
writeLog("XXPER",pageContext,"After set the VO value "+convertedDateValue);
}
}else
writeLog("XXPER",pageContext,"dateBean is null ");
writeLog("XXPER",pageContext,"End PFR XXPERMAFinalRatingsPageCO ");
super.processFormRequest(pageContext, webBean);
writeLog("XXPER",pageContext,"End PFR XXPERMAFinalRatingsPageCO (After Super Call )");
}
public void writeLog(String moduleName, OAPageContext pageContext, String diagText)
{
if(pageContext.isLoggingEnabled(OAWebBeanConstants.STATEMENT))
{
System.out.println(moduleName+" : "+diagText);
pageContext.writeDiagnostics(moduleName,diagText,OAWebBeanConstants.STATEMENT);
}
}
/**
*
* Method to execute SQL.
*/
public Object executeSql(String pSqlStmt, OAPageContext pageContext , OAWebBean webBean)
{

OADBTransaction tx = pageContext.getApplicationModule(webBean).getOADBTransaction();// (OADBTransaction)getOADBTransaction();
Object lObject = null;

// Create the callable statement
CallableStatement lCstmt = (CallableStatement)tx.createCallableStatement(pSqlStmt, 1);
ResultSet rs = null;
try
{
rs = lCstmt.executeQuery();
while(rs.next())
{
lObject = rs.getObject(1);
}
}
catch (Exception e)
{
//throw OAException.wrapperException(e);
}
finally
{
try {
if(rs!=null)
rs.close();
if(lCstmt != null)
lCstmt.close();
}
catch(Exception e) {
throw OAException.wrapperException(e);
}
}
return lObject;
} // executeSql
public void setAttribute3(OAPageContext pageContext, String dateValue)
{
OAApplicationModule rootAM = pageContext.getRootApplicationModule();
OAApplicationModule apprAM = (OAApplicationModule)rootAM.findApplicationModule("AppraisalsAM");
OAViewObject appraisalVO = (OAViewObject)apprAM.findViewObject("AppraisalVO");
writeLog("XXPER",pageContext,"appraisalVO "+appraisalVO);
if(appraisalVO !=null)
{
AppraisalVORowImpl appraisalVORow = (AppraisalVORowImpl) appraisalVO.getCurrentRow();
if(appraisalVORow !=null)
{
int attrCount = appraisalVO.getAttributeCount();
writeLog("XXPER",pageContext,"Attrbuute count "+attrCount);
String[] attributeNames = appraisalVORow.getAttributeNames();
appraisalVORow.setAttribute3(dateValue);
}
}

}
public String getAttribute3(OAPageContext pageContext)
{
OAApplicationModule rootAM = pageContext.getRootApplicationModule();
OAApplicationModule apprAM = (OAApplicationModule)rootAM.findApplicationModule("AppraisalsAM");
String attribute3Value = "N";
OAViewObject appraisalVO = (OAViewObject)apprAM.findViewObject("AppraisalVO");
writeLog("XXPER",pageContext,"appraisalVO "+appraisalVO);
if(appraisalVO !=null)
{
AppraisalVORowImpl appraisalVORow = (AppraisalVORowImpl) appraisalVO.getCurrentRow();
if(appraisalVORow !=null)
{
int attrCount = appraisalVO.getAttributeCount();
writeLog("XXPER",pageContext,"Attrbuute count "+attrCount);
String[] attributeNames = appraisalVORow.getAttributeNames();
writeLog("XXPER",pageContext," AppraisalId :- "+ appraisalVORow.getAppraisalId());
attribute3Value = (String)appraisalVORow.getAttribute3();
String attribute1Value = (String)appraisalVORow.getAttribute1();//getAttribute2
String attribute2Value = (String)appraisalVORow.getAttribute2();
writeLog("XXPER",pageContext," attribute3Value :- "+attribute3Value + " attribute1Value "+ attribute1Value +"attribute2Value "+attribute2Value);
}else
{
writeLog("XXPER",pageContext," appraisalVORow is null ");
}
}else
{
writeLog("XXPER",pageContext," appraisalVO is null ");
}
return attribute3Value;
}
}

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