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




No comments:

Post a Comment