Wednesday, 13 June 2012

How insert values in table directly and call processrequest many time with different case on same oaf Page


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.message.OAMessageTextInputBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageCheckBoxBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.sql.*;

/**
 * Controller for ...
 */
public class HumanResourceController 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);


System.out.println("I am Human Resource Page processRequest of HR page");
String eno=pageContext.getParameter("EmployeeNo");
String ena=pageContext.getParameter("EmployeeName");
String endgn=pageContext.getParameter("EmployeeDesignation");
String endv=pageContext.getParameter("EmployeeDivision");
String endp=pageContext.getParameter("EmployeeDepartment");
String encty=pageContext.getParameter("EmployeeCity");
//--------
String  empno =pageContext.getParameter("EmpNo");
String emppn=pageContext.getParameter("EmpPositionName");
String emplev=pageContext.getParameter("EmpLevel");
String  empgr =pageContext.getParameter("EmpGrade");
String empres=pageContext.getParameter("EmpResources");
String empdiv=pageContext.getParameter("EmpDivision");
String  empdeptt =pageContext.getParameter("EmpDepartment");
String empsubdeptt=pageContext.getParameter("EmpSubDepartment");
String empfun=pageContext.getParameter("EmpFunction");
String  empcty =pageContext.getParameter("EmpCity");
String emprpt=pageContext.getParameter("EmpReportTo");
String empst=pageContext.getParameter("EmpStatus");
String empct=pageContext.getParameter("EmpCaseType");
//---


String  emprno =pageContext.getParameter("EmpRno");
String emprname=pageContext.getParameter("EmpRname");
String emprdesignation=pageContext.getParameter("EmpRdesignation");
String  emprdepartment =pageContext.getParameter("EmpRdepartment");
String emprgrade=pageContext.getParameter("EmpRgrade");
String emprcity=pageContext.getParameter("EmpRcity");
String emprdol=pageContext.getParameter("EmpRdol");

//-




OAMessageTextInputBean  tibno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empno");
tibno.setValue(pageContext,eno);
tibno.setDisabled(true);

OAMessageTextInputBean  tibname= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empname");
tibname.setValue(pageContext,ena);
tibname.setDisabled(true);

OAMessageTextInputBean  tibdesignation = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empdesignation");
tibdesignation.setValue(pageContext,endgn);
tibdesignation.setDisabled(true);

OAMessageTextInputBean  tibdepartment = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empdepartment");
tibdepartment.setValue(pageContext,endv);
tibdepartment.setDisabled(true);

OAMessageTextInputBean  tibdivision= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empdivision");
tibdivision.setValue(pageContext,endp);
tibdivision.setDisabled(true);

OAMessageTextInputBean  tibcity = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("empcity");
tibcity.setValue(pageContext,encty);
tibcity.setDisabled(true);
//------------------------------------------------------------



OAMessageTextInputBean  tibnewno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("newrno");
tibnewno.setValue(pageContext,empno);
tibnewno.setDisabled(true);

OAMessageTextInputBean  tibpname= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("pname");
tibpname.setValue(pageContext,emppn);
tibpname.setDisabled(true);

OAMessageTextInputBean  tibelevel = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("elevel");
tibelevel.setValue(pageContext,emplev);
tibelevel.setDisabled(true);

OAMessageTextInputBean  tibegrade = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("egrade");
tibegrade.setValue(pageContext,empgr);
tibegrade.setDisabled(true);

OAMessageTextInputBean  tiberequired= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("erequired");
tiberequired.setValue(pageContext,empres);
tiberequired.setDisabled(true);

OAMessageTextInputBean  tibedivision = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("edivision");
tibedivision.setValue(pageContext,empdiv);
tibedivision.setDisabled(true);

OAMessageTextInputBean  tibedepartment = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("edepartment");
tibedepartment.setValue(pageContext,empdeptt);
tibedepartment.setDisabled(true);

OAMessageTextInputBean  tibesubdepartment= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("esubdepartment");
tibesubdepartment.setValue(pageContext,empsubdeptt);
tibesubdepartment.setDisabled(true);

OAMessageTextInputBean  tibefunction = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("efunction");
tibefunction.setValue(pageContext,empfun);
tibefunction.setDisabled(true);

OAMessageTextInputBean  tibecity = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("ecity");
tibecity.setValue(pageContext,empcty);
tibecity.setDisabled(true);

OAMessageTextInputBean  tibereportto= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("ereporto");
tibereportto.setValue(pageContext,emprpt);
tibereportto.setDisabled(true);

OAMessageTextInputBean  tibestatus = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("estatus");
tibestatus.setValue(pageContext,empst);
tibestatus.setDisabled(true);
OAMessageTextInputBean  tibecasetype = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("ecasetype");
tibecasetype.setValue(pageContext,empct);
tibecasetype.setDisabled(true);
//------------------------------------------------------------




OAMessageTextInputBean  tibrno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempno");
tibrno.setValue(pageContext,emprno);
tibrno.setDisabled(true);
OAMessageTextInputBean  tibrname= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempname");
tibrname.setValue(pageContext,emprname);
tibrname.setDisabled(true);

OAMessageTextInputBean  tibrdesignation = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempdesignation");
tibrdesignation.setValue(pageContext,emprdesignation);
tibrdesignation.setDisabled(true);

OAMessageTextInputBean  tibrdivision = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempdivision");
tibrdivision.setValue(pageContext,emprdepartment);
tibrdivision.setDisabled(true);

OAMessageTextInputBean  tibrgrade= (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempgrade");
tibrgrade.setValue(pageContext,emprgrade);
tibrgrade.setDisabled(true);

OAMessageTextInputBean  tibrcity = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rempcity");
tibrcity.setValue(pageContext,emprcity);
tibrcity.setDisabled(true);

OAMessageTextInputBean  tibrdol = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("rdol");
tibrdol.setValue(pageContext,emprdol);
tibrdol.setDisabled(true);
//---------------------

  if("2".equals(pageContext.getParameter("x"))){
  OAMessageTextInputBean  tibnewno1 = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("newrno");
  tibnewno1.setDisabled(true);
  OAMessageTextInputBean  tibhrcommet1 = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("hrcomments");
  tibhrcommet1.setDisabled(true);
  OAMessageCheckBoxBean  cbhrvacan1 = (OAMessageCheckBoxBean)webBean.findIndexedChildRecursive("vacancy");
  cbhrvacan1.setDisabled(true);
  OAMessageTextInputBean  tibhrjustify1 = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("justify");
   tibhrjustify1.setDisabled(true);
     }//end if

//-----
if("3".equals(pageContext.getParameter("y"))){
  OAMessageTextInputBean  tibrefno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("refno");
  tibrefno.setValue(pageContext,empno);
  tibrefno.setDisabled(true);

  OAMessageTextInputBean  tibheadCount = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headCount");
  tibheadCount.setDisabled(true);

  OAMessageTextInputBean  tibheadcountdiv = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headcountdiv");
  tibheadcountdiv.setDisabled(true);
 
  OAMessageTextInputBean  tibheadcountdept = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headcountdept");
  tibheadcountdept.setDisabled(true);

  OAMessageTextInputBean  tibbudgetedheadcount = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedheadcount");
  tibbudgetedheadcount.setDisabled(true);
 
  OAMessageTextInputBean  tibbudgetedHeadcountDiv = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedHeadcountDiv");
  tibbudgetedHeadcountDiv.setDisabled(true);
 
  OAMessageTextInputBean  tibbudgetedheadcountdept = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedheadcountdept");
   tibbudgetedheadcountdept.setDisabled(true);
     }//end if
//----

if("4".equals(pageContext.getParameter("z"))){
  OAMessageTextInputBean  tibvadate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("vadate");
  tibvadate.setDisabled(true);

  OAMessageTextInputBean  tibvareDate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("vareDate");
  tibvareDate.setDisabled(true);
 
  OAMessageTextInputBean  tibrefCloseDate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("refCloseDate");
  tibrefCloseDate.setDisabled(true);
 }//end if






   
}

  /**
   * 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);

    if(pageContext.getParameter("SubmitComments")!=null){
   OAMessageTextInputBean  tibnewno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("newrno");
   String reqno=(String)tibnewno.getValue(pageContext);

   OAMessageTextInputBean  tibhrcommet = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("hrcomments");
   String hrcoment=(String)tibhrcommet.getValue(pageContext);


   OAMessageCheckBoxBean  cbhrvacan = (OAMessageCheckBoxBean)webBean.findIndexedChildRecursive("vacancy");
   String hrvacancy=(String)cbhrvacan.getValue(pageContext);
 

   OAMessageTextInputBean  tibhrjustify = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("justify");
   String hrjustify=(String)tibhrjustify.getValue(pageContext);
 
   System.out.println("Do the Updatation regarding EmpRequisitionNo.==="+reqno);
   OAApplicationModule am=pageContext.getApplicationModule(webBean);

try{
Connection conn =am.getOADBTransaction().getJdbcConnection();
Statement stmt = conn.createStatement();
int r=stmt.executeUpdate("update employeerequisitiondetail  set commentsByDepttNHR='"+hrcoment+"',Vacancy2bAnnounced='"+hrvacancy+"',justification='"+hrjustify+"' where employeerequistionno="+reqno+" ");
                                                           
System.out.println("I am in TOP ProcessFormRequest  Succesfully if result ====="+r);
am.getOADBTransaction().commit();
stmt.close();
}catch(Exception e){System.out.println(e.toString());}

HashMap params = new HashMap();
params.put("x","2");
pageContext.setForwardURLToCurrentPage(params, true, OAWebBeanConstants.ADD_BREAD_CRUMB_NO,OAWebBeanConstants.IGNORE_MESSAGES);
    }




if(pageContext.getParameter("workforcebtn")!=null){
 OAMessageTextInputBean  tibnewrf = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("newrno");
 String reqrf=(String)tibnewrf.getValue(pageContext);



OAMessageTextInputBean  tibhrrefno = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("refno");
String hrrefno=(String)tibhrrefno.getValue(pageContext);

OAMessageTextInputBean  tibhrheadcount = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headCount");
String hrheadcount=(String)tibhrheadcount.getValue(pageContext);

OAMessageTextInputBean  tibhrheadcountdiv = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headcountdiv");
String hrheadcountdiv=(String)tibhrheadcountdiv.getValue(pageContext);

OAMessageTextInputBean  tibhrheadcountdept = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("headcountdept");
String hrheadcountdept=(String)tibhrheadcountdept.getValue(pageContext);

OAMessageTextInputBean  tibhrbudgetedheadcount = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedheadcount");
String hrbudgetedheadcount=(String)tibhrbudgetedheadcount.getValue(pageContext);

OAMessageTextInputBean  tibhrbudgetedHeadcountDiv = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedHeadcountDiv");
String hrbudgetedHeadcountDiv=(String)tibhrbudgetedHeadcountDiv.getValue(pageContext);

OAMessageTextInputBean  tibhrbudgetedheadcountdept = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("budgetedheadcountdept");
String hrbudgetedheadcountdept=(String)tibhrbudgetedheadcountdept.getValue(pageContext);


System.out.println("Do the Updatation regarding EmpRequisitionNo.==="+reqrf);
 OAApplicationModule am=pageContext.getApplicationModule(webBean);


try{
Connection conn =am.getOADBTransaction().getJdbcConnection();
Statement stmt = conn.createStatement();
int r=stmt.executeUpdate("insert into HRWSA(HRREFNO,HEADCOUNTOB,HEADCOUNTDIV,HEADCOUNTDEPT,HEADCOUNTBUG,HEANDCOUNTBUGDIV,HEANDCOUNTBUGDEPT)  values("+reqrf+","+hrheadcount+","+hrheadcountdiv+","+hrheadcountdept+","+hrbudgetedheadcount+","+hrbudgetedHeadcountDiv+","+hrbudgetedheadcountdept+")");
                                                           
System.out.println("I am in TOP ProcessFormRequest  Succesfully if result ====="+r);
am.getOADBTransaction().commit();
stmt.close();
}catch(Exception e){System.out.println(e.toString());}
HashMap params = new HashMap();
params.put("y","3");
pageContext.setForwardURLToCurrentPage(params, true, OAWebBeanConstants.ADD_BREAD_CRUMB_NO,OAWebBeanConstants.IGNORE_MESSAGES);

   }//end if hr
 

//---


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

OAMessageTextInputBean  tibrevadate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("vadate");
String revadate=(String)tibrevadate.getValue(pageContext);


OAMessageTextInputBean  tibrevareDate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("vareDate");
String revareDate=(String)tibrevareDate.getValue(pageContext);

OAMessageTextInputBean  tibrerefCloseDate = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("refCloseDate");
String rerefCloseDate=(String)tibrerefCloseDate.getValue(pageContext);


OAMessageTextInputBean  tibrfn = (OAMessageTextInputBean)webBean.findIndexedChildRecursive("newrno");
String rfn=(String)tibrfn.getValue(pageContext);

System.out.println("Do the Updatation regarding EmpRequisitionNo.==="+rfn);
 OAApplicationModule am=pageContext.getApplicationModule(webBean);


try{
Connection conn =am.getOADBTransaction().getJdbcConnection();
Statement stmt = conn.createStatement();

int r=stmt.executeUpdate("insert into recruitOperation(Rerefno,Vacananndate,Vacanreopendate,Refclosuredate)  values("+rfn+","+revadate+","+revareDate+","+rerefCloseDate+")");
                                                           
System.out.println("I am in TOP ProcessFormRequest  Succesfully if result ====="+r);
am.getOADBTransaction().commit();
stmt.close();
}catch(Exception e){System.out.println(e.toString());}
HashMap params = new HashMap();
params.put("y","4");
pageContext.setForwardURLToCurrentPage(params, true, OAWebBeanConstants.ADD_BREAD_CRUMB_NO,OAWebBeanConstants.IGNORE_MESSAGES);

   }//end if hr





   
  }
 
}

No comments:

Post a Comment