Friday, 27 April 2012

Method to Print View Object wirtten in AM called by Controller of the Page

package oracle.apps.ak.test.EOPackage;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
//  ---------------------------------------------------------------
//  ---    File generated by Oracle Business Components for Java.
//  ---------------------------------------------------------------

public class EOPackageModuleImpl extends OAApplicationModuleImpl
{


   public  void printViewObject()
   {

   //get a handle to the View Object that we wish to initialize
    OAViewObject vo = (OAViewObject)getEmprequisitionView1();
      // Execute the query, print results to the screen.
      vo.executeQuery();
      while (vo.hasNext()) {
         Row row = vo.next();
         String rowDataStr = "";

         // How many attributes (columns) is the View Object using?
         int numAttrs = vo.getAttributeCount();

         // Column numbers start with 0, not 1.
         for (int columnNo = 0; columnNo < numAttrs; columnNo++) {

           // See also Row.getAttribute(String name).
           Object attrData = row.getAttribute(columnNo);
           rowDataStr += (attrData + "\t");
         }
         System.out.println(rowDataStr);
      }
   }




public void OurInsertMethod(String empid, String empname, String empdesign, String empdepart, String empdiv, String emploc ){

System.out.println("I am insert method in Am"+empid+empname);
 //get a handle to the View Object that we wish to initialize
    OAViewObject vo = (OAViewObject)getEmprequisitionView1();
    if(!vo.isPreparedForExecution()){
    vo.executeQuery();
    }

    //Create a blank Row
    
     Row row = vo.createRow();
    //Attach that blank row to the VO. Data will be fed into this row, when the user types into the fields
   //row.
    
      vo.insertRow(row);
    //Set the status of the blank row to initialized. This tells OA Framework that record is blank and must not be included in DML
    //Operations until    changes are made to its underlying VO [via screen fields]
   row.setNewRowState(Row.STATUS_INITIALIZED);
}
   
 //method defined to commit the tractions.  
public void saveDataToSimpleTable()
{
        getDBTransaction().commit();
}


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

  /**
   *
   * Container's getter for EmprequisitionView1
   */
  public EmprequisitionViewImpl getEmprequisitionView1()
  {
    return (EmprequisitionViewImpl)findViewObject("EmprequisitionView1");
  }

  /**
   *
   * Sample main for debugging Business Components code using the tester.
   */
  public static void main(String[] args)
  {
    launchTester("oracle.apps.ak.test.EOPackage", "EOPackageModuleLocal");
  }
}

Thursday, 26 April 2012

AM Appliction Module Containing InsertMethod Called By Controller

package oracle.apps.ak.test.EOPackage;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
public class EOPackageModuleImpl extends OAApplicationModuleImpl
{
public void OurInsertMethod(String empid, String empname, String empdesign, String empdepart, String empdiv, String emploc ){
System.out.println("I am insert method in Am"+empid+empname);
 //get a handle to the View Object that we wish to initialize
    OAViewObject vo = (OAViewObject)getEmprequisitionView1();
    if(!vo.isPreparedForExecution()){
    vo.executeQuery();
    }
    //Create a blank Row
    Row row = vo.createRow();
    //Attach that blank row to the VO. Data will be fed into this row, when the user types into the fields
   //row.
     vo.insertRow(row);
    //Set the status of the blank row to initialized. This tells OA Framework that record is blank and must not be included in DML
    //Operations until    changes are made to its underlying VO [via screen fields]
   row.setNewRowState(Row.STATUS_INITIALIZED);
}
 public void saveDataToSimpleTable()
{        getDBTransaction().commit();}
  /**
   *
   * This is the default constructor (do not remove)
   */
  public EOPackageModuleImpl()
  {
  }

  /**
   *
   * Container's getter for EmprequisitionView1
   */
  public EmprequisitionViewImpl getEmprequisitionView1()
  {
    return (EmprequisitionViewImpl)findViewObject("EmprequisitionView1");
  }

  public static void main(String[] args)
  {
    launchTester("oracle.apps.ak.test.EOPackage", "EOPackageModuleLocal");
  }
}

Controll Class in OAF


package oracle.apps.ak.test.EOPackage.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.OAApplicationModule;
import java.io.Serializable;
/**
 * Controller for ...
 */
public class EmpolyeeController 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);
  String userId = pageContext.getParameter("EmployeeID");
  String userName = pageContext.getParameter("EmployeeName");
  String userDesignation = pageContext.getParameter("EmployeeDesignation");
  String userDepartment = pageContext.getParameter("EmployeeDepartment");
  String userDivision = pageContext.getParameter("EmployeeDivision");
  String userLocation = pageContext.getParameter("EmployeeLocation");
  Serializable[] params={userId,userName,userDesignation,userDepartment,userDivision,userLocation};
  am.invokeMethod("OurInsertMethod",params);
  }

  /**
   * 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);
    am.invokeMethod("saveDataToSimpleTable") ;

}
}