For loop Row Iteration

For loop Row Iteration



We can use below code to use for loop row iterations when a check box is selected.


Only selected rows will be looped and submitted.

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

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAViewObject;
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.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageCheckBoxBean;

import oracle.jbo.Row;

import XXTEST.oracle.apps.XXTEST.ParentChildRelation.server.XXTESTDetailsVORowImpl;



/**
 * Controller for ...
 */
public class XXTESTParentChildRelationCO 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);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    OAViewObject vo = (OAViewObject)am.findViewObject("XXTESTDetailsVO1");

  }

  /**
   * 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);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    OAViewObject vo = (OAViewObject)am.findViewObject("XXTESTDetailsVO1");

    String customerID = pageContext.getParameter("CustomerID");
    String customerName = pageContext.getParameter("CustomerNumber");

    System.out.println("customer ID " + customerID);
    System.out.println("Customer Name " + customerName);

    if (pageContext.getParameter("Go") != null)
    {
      vo.setWhereClause(null);
      vo.setWhereClauseParams(null);
      vo.setWhereClause("CUSTOMER_ID = :1 OR CUSTOMER_NAME = :2");
      vo.setWhereClauseParam(0, customerID);
      vo.setWhereClauseParam(1, customerName);
      System.out.println("query" + vo.getQuery());
      vo.executeQuery();
    }
    // Getting selected parent project details
    if (pageContext.getParameter("Submit") != null)
    {
      OAMessageCheckBoxBean child = 
        (OAMessageCheckBoxBean)webBean.findChildRecursive("Child");
      child.setRendered(Boolean.TRUE);

      OAMessageCheckBoxBean Parent = 
        (OAMessageCheckBoxBean)webBean.findChildRecursive("Parent");
      Parent.setRendered(Boolean.FALSE);
      
      OASubmitButtonBean SelectParent = (OASubmitButtonBean)webBean.findChildRecursive("Submit");
      SelectParent.setRendered(Boolean.FALSE);

      XXTESTDetailsVORowImpl row = null;

      Row rows[] = vo.getFilteredRows("Parent", "Y");

      int selectedRowLenth = rows.length;

      if (selectedRowLenth > 0)
      {

        for (int i = 0; i < selectedRowLenth; i++)
        {
          row = (XXTESTDetailsVORowImpl)rows[i];
          String ProjectNumber = (String)row.getAttribute("ProjectNumber");
          System.out.println("project number" + ProjectNumber);
        }
        OAException infoMsg = 
          new OAException("Deleted The Selected Rows--Count-->" + 
                          selectedRowLenth, OAException.INFORMATION);
        throw infoMsg;
      }

      else
      {
        OAException warningMsg = 
          new OAException("Plese Select The Rows", OAException.WARNING);
        throw warningMsg;
      }
    }
    // Submit Button logic ends

    //Clear is the id of the clear button
    if (pageContext.getParameter("Clear") != null)
    {
      pageContext.forwardImmediatelyToCurrentPage(null, false, null);
    }

  }

}

Post a Comment

0 Comments