Friday 30 September 2011

Creation of Side Navigation dynamically...to the page

/*===========================================================================+
| Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
| All rights reserved. |
+===========================================================================+
| HISTORY |
+===========================================================================*/
package cisco.oracle.apps.pa.revenue.webui;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OASideBarHelper;
import oracle.apps.fnd.framework.webui.beans.nav.OASideNavBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.nav.OALinkBean;

/**
* Controller for ...
*/
public class SideNavigationCO1 extends OAControllerImpl
{
public static final String RCS_ID="$Header$";
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);
createSideNavigation(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);
}

public void createSideNavigation(OAPageContext pageContext, OAWebBean webBean)
{
OASideNavBean sideNav = (OASideNavBean)createWebBean(pageContext,
OAWebBeanConstants.SIDE_NAV_BEAN,
null, // no need to specify a data type
"sideNav" // always specify name
);
OAStackLayoutBean search =
(OAStackLayoutBean)createWebBean(pageContext,
"/cisco/oracle/apps/pa/revenue/webui/SideSearchRN",
"SideSearchRN", // always specify name
true); // region created in Oracle
sideNav.addIndexedChild(search);
OAPageLayoutBean pageBean = (OAPageLayoutBean)webBean.findIndexedChildRecursive("pageLayoutRN");

pageBean.addIndexedChild(sideNav);

OALinkBean link1 = (OALinkBean)createWebBean(pageContext,
OAWebBeanConstants.LINK_BEAN,
null,
"AllOfferings");
link1.setText("All Offerings");
link1.setDestination("OA.jsp?page=/cisco/oracle/apps/pa/revenue/webui/AllIOfferingPG&retainAM=Y");
sideNav.addIndexedChild(link1);

OALinkBean link2 = (OALinkBean)createWebBean(pageContext,
OAWebBeanConstants.LINK_BEAN,
null,
"MyOfferings");
link1.setText("My Offerings");
link1.setDestination("OA.jsp?page=/cisco/oracle/apps/pa/revenue/webui/MyOfferingPG&retainAM=Y");
sideNav.addIndexedChild(link2);

OALinkBean link3 = (OALinkBean)createWebBean(pageContext,
OAWebBeanConstants.LINK_BEAN,
null,
"Alerts");
link1.setText("My Offerings");
link1.setDestination("OA.jsp?page=/cisco/oracle/apps/pa/revenue/webui/AlertPG&retainAM=Y");
sideNav.addIndexedChild(link3);
search.render(true);
sideNav.render(true);
link1.render(true);
link2.render(true);
link3.render(true);
pageBean.render(true);
}
}

Monday 12 September 2011

OAF Page Personalization....adding two columns and button as programatically to the table region


  private void addSelectColumn(OAPageContext pageContext, OAWebBean webBean)
  {
    String voName = "AvailableCCTrxnVO";
   
    OAAdvancedTableBean unUsedCCTxnsTable = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("TransactionsListOnlyT");
   
    if(unUsedCCTxnsTable != null) //If not able to find the table, skip the process
    {
      //Create new column Category to the table
       OAColumnBean categoryCol = (OAColumnBean)createWebBean(pageContext, COLUMN_BEAN, null, "XxcfiCategoryColumn1");
       OASortableHeaderBean column1Header = (OASortableHeaderBean)createWebBean(pageContext, SORTABLE_HEADER_BEAN, null, "XxcfiCategoryColumn1Header1");
       column1Header.setText("Category");
       categoryCol.setColumnHeader(column1Header);
       // Create the actual leaf item under the first column
       OAMessageStyledTextBean leaf1 = (OAMessageStyledTextBean)createWebBean(pageContext, MESSAGE_STYLED_TEXT_BEAN, null, "XxcfiCategoryColumnLeaf1");
       leaf1.setViewAttributeName("Category");
       categoryCol.addIndexedChild(leaf1);
      
      //Create Multi Select Check box
      OAMultipleSelectionBean mBean = (OAMultipleSelectionBean)createWebBean(pageContext, MULTIPLE_SELECTION_BEAN, null, "XxcfiMultiSelect1");
      mBean.setViewUsageName(voName);
      mBean.setViewAttributeName("SelectFlag");
      mBean.setDisabledBinding(new OADataBoundValueViewObject(mBean, "DisableSelection", voName));
      mBean.setText("Select:");
     
      //Create selection button Categorize as Personal and add it to Multi Select Check box
      OASelectionButtonBean categorizePersoanlBtn = (OASelectionButtonBean)createWebBean(pageContext, BUTTON_SELECTION_BEAN, null, "XxcfiCategorizeAsPersonal1");
      categorizePersoanlBtn.setText("Categorize as Personal");
      mBean.addIndexedChild(categorizePersoanlBtn);
     
      /*
      //Create selection button Categorize as Business and add it to Multi Select Check box
      OASelectionButtonBean categorizeBusinessBtn = (OASelectionButtonBean)createWebBean(pageContext, BUTTON_SELECTION_BEAN, null, "XxcfiCategorizeAsBusiness1");
      categorizeBusinessBtn.setText("Categorize as Business");
      mBean.addIndexedChild(categorizeBusinessBtn);
      */

      //Add Multi Select Check box to the table
      unUsedCCTxnsTable.setTableSelection(mBean);
     
      //Add new column Categroy to the table
       unUsedCCTxnsTable.addIndexedChild(categoryCol);
    }
  }


For multiple selection bean item
the following code has to be use for selecting or deselecting


  /*
   * Get the specified VO from application module. If not found in AM, create a view object and return
   */
  public OAViewObjectImpl getVO(OAPageContext pageContext, OAWebBean webBean, String voName, String voPath)
  {
 
      logDebugMessage(pageContext, "Entered getVO", OAFwkConstants.STATEMENT);
      OAApplicationModule am = pageContext.getApplicationModule(webBean);
      OAViewObjectImpl vo = (OAViewObjectImpl)am.findViewObject(voName);
     
      logDebugMessage(pageContext, "vo = "+vo, OAFwkConstants.STATEMENT);
     
      if (vo == null) {
          return (OAViewObjectImpl)am.createViewObject(voName, voPath);
      }

      String path = vo.getViewDefinition().getFullName();
      if (path.equals(voPath)) {
          return vo;
      } else {
          vo.remove();
          return (OAViewObjectImpl)am.createViewObject(voName, voPath);
      }
  }
 
  public void logDebugMessage(OAPageContext pageContext,String messageText, int logLevel)
  {
    if (pageContext.isLoggingEnabled(logLevel))
      pageContext.writeDiagnostics(this, messageText,logLevel);
  }


  private void categorizeCCTransactions(OAPageContext pageContext, OAWebBean webBean)
  {
    String voName = "AvailableCCTrxnVO";
   
    String categorizeAsPersonal = pageContext.getParameter("XxcfiCategorizeAsPersonal1");
    String categorizeAsBusiness = pageContext.getParameter("XxcfiCategorizeAsBusiness1");
   
    if(categorizeAsPersonal != null || categorizeAsBusiness != null)
    {
      OAApplicationModule am = pageContext.getApplicationModule(webBean);
      OAViewObject vo = (OAViewObject)am.findViewObject(voName);
      Row[] rows = vo.getFilteredRows("SelectFlag", "Y");
      StringBuffer whereClause = new StringBuffer();
      if(rows != null && rows.length > 0)
      {
        OAViewObject ccVO = getVO(pageContext, webBean, "XxcfiCreditCardTransactionsVO1", "oracle.apps.ap.oie.creditCard.server.CreditCardTransactionsVO");
        whereClause.append(" trx_id in (");
        for (int i = 0; i < rows.length; i++)
        {
          whereClause.append(rows[i].getAttribute("TrxId"));
          if(i+1 < rows.length)
            whereClause.append(",");

        }
        whereClause.append(")");
        ccVO.setWhereClause(null);
        ccVO.setWhereClause(whereClause.toString());
        ccVO.executeQuery();
      
        CreditCardTransactionsVORowImpl row = (CreditCardTransactionsVORowImpl)ccVO.first();
        while(row != null)
        {
          CreditCardTransactionEOImpl eo = ((CreditCardTransactionEOImpl)row.getEntity(0));
         
          if(categorizeAsPersonal != null)
          {
            row.setCategory("PERSONAL");
            eo.setCategory("PERSONAL");
            eo.setReportHeaderId(new Number(-888999));
          }
          else if(categorizeAsBusiness != null)
          {
            row.setCategory("BUSINESS");
            eo.setCategory("BUSINESS");
          }
         
          row = (CreditCardTransactionsVORowImpl)ccVO.next();
        }
       
        am.getOADBTransaction().commit();
       
        String selectedCard = pageContext.getParameter("CreditCardPoplist");
        pageContext.putTransactionValue("SelectedCard", selectedCard);
        Serializable[] params = {selectedCard};
        am.invokeMethod("initCCTrxn", params);
      }
    }

  }

before page change


We need to add two more columns to the table region such as select check box and category
And we need to add one button as category as personal
after page change:

when category as personal select flag is disable

when category as business then select flag is enabled




Tuesday 6 September 2011

How to Use JAVA Script in OAF Page

Call this method from Process Request Or Process Form Request based on the requirement

protected void changeLinkColor(OAPageContext pageContext, OAWebBean webBean)
      {
        //Create Java script function to hide Select All and Select None links
        StringBuffer scriptFunction = new StringBuffer(400);
        scriptFunction.append("function changeLinkColor(){");
        scriptFunction.append("  var arrElements = document.getElementsByTagName(\"a\");");
        scriptFunction.append("  for (var i=0; i<arrElements.length; i++) {");
        scriptFunction.append("      var element=arrElements[i];");
        scriptFunction.append("    if(element.id.indexOf(\"ManagerName\") != -1)");
        scriptFunction.append("      element.style.color = '#ed1c24'; ");
        scriptFunction.append("    }");
        scriptFunction.append("  }");

        //put the java script function in pagecontext
        pageContext.putJavaScriptFunction("changeTableLinksColorToRed", scriptFunction.toString());

        OAWebBean body = pageContext.getRootWebBean();
        if (body instanceof OABodyBean)
          ((OABodyBean)body).setOnLoad("changeLinkColor();"); //call the javascript function when the page loads
      }