public void intEmployee(String empName,String empId)
{
String voName="DynamicVO";
OAViewObject vo = (OAViewObject) findViewObject(voName);
Number empNum = null;
try { empNum = new Number(empId);
}
catch(Exception e) { }
if (vo != null)
{ vo.setWhereClause(null);
vo.setWhereClauseParams(null);
if(!empName.equals("") && !empId.equals("") )
{ String s1 = " EMPLOYEE_ID = "+empNum+" AND "+" UPPER(EMPLOYEE_NAME) LIKE "+"UPPER("+"'"+empName+"'"+")";
 vo.setWhereClause(s1);
}
else if(!empName.equals(""))
{ String s2 = " UPPER(EMPLOYEE_NAME) LIKE "+"UPPER("+"'"+empName+"'"+")";
 vo.setWhereClause(s2);
}
else if(!empId.equals(""))
{ String s3 = " EMPLOYEE_ID = "+ empNum; vo.setWhereClause(s3);
}
}
vo.executeQuery();
}


public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);

OAApplicationModule am = pageContext.getApplicationModule(webBean);
String searchEmpName = pageContext.getParameter("EmployeeName");
String searchEmpId = pageContext.getParameter("EmployeeId");
System.out.println("EmployeeName: "+searchEmpName);
System.out.println("EmployeeId: "+searchEmpId);
if (pageContext.getParameter("Search") != null)
{
Serializable[] parameters = { searchEmpName, searchEmpId };
Class[] paramTypes = { String.class, String.class };
am.invokeMethod("intEmployee",parameters,paramTypes);
pageContext.setForwardURLToCurrentPage(null,true,OAWebBeanConstants.ADD_BREAD_CRUMB_NO,OAException.ERROR);
}
}


public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String sessionVariable = (String)pageContext.getSessionValue("SessionVariable");
if (("N".equals(sessionVariable)) || (sessionVariable == null))
{ am.invokeMethod("intEmployee1");
  pageContext.putSessionValue("SessionVariable","Y");
}
}



public void intEmployee1()
{
OADBTransactionImpl dbTx = (OADBTransactionImpl)getTransaction();
Transaction txn = getTransaction();
String sqlText = "SELECT Employee1.EMPLOYEE_ID AS EMPLOYEE_ID,\n" +
"Employee1.FULL_NAME AS EMPLOYEE_NAME,\n" +
"Employee1.EMAIL_ADDRESS AS EMPLOYEE_EMAIL,\n" +
"Employee2.EMPLOYEE_ID AS MANAGER_ID,\n" +
"Employee2.FULL_NAME AS MANAGER_NAME,\n"+
"Employee2.EMAIL_ADDRESS AS MANAGER_EMAIL\n"+
"FROM FWK_TBX_EMPLOYEES Employee1,\n" +
"FWK_TBX_EMPLOYEES Employee2\n"+
"WHERE Employee1.MANAGER_ID = Employee2.EMPLOYEE_ID";

OAViewDef viewDef = dbTx.createViewDef();
viewDef.setSql(sqlText);
viewDef.setExpertMode(true);
viewDef.setViewRowClass("oracle.apps.fnd.framework.server.OAViewRowImpl");
viewDef.addSqlDerivedAttrDef("EMPLOYEE_ID", //Attr name
"EMPLOYEE_ID",
"oracle.jbo.domain.Number",
Types.NUMERIC, true, true,
AttributeDef.READONLY, (byte)15);
viewDef.addSqlDerivedAttrDef("EMPLOYEE_NAME", //Attr name
"EMPLOYEE_NAME",
"java.lang.String",
Types.VARCHAR, true, true,
AttributeDef.READONLY, (byte)7);
viewDef.addSqlDerivedAttrDef("EMPLOYEE_EMAIL", //Attr name
"EMPLOYEE_EMAIL",
"java.lang.String",
Types.VARCHAR,true, true,
AttributeDef.READONLY, (byte)15);
viewDef.addSqlDerivedAttrDef("MANAGER_ID", //Attr name
"MANAGER_ID",
"oracle.jbo.domain.Number",
Types.NUMERIC, true, true,
AttributeDef.READONLY, (byte)15);
viewDef.addSqlDerivedAttrDef("MANAGER_NAME", //Attr name
"MANAGER_NAME",
"java.lang.String",
Types.VARCHAR, true, true,
AttributeDef.UPDATEABLE, (byte)7);
viewDef.addSqlDerivedAttrDef("MANAGER_EMAIL", //Attr name
"MANAGER_EMAIL",
"java.lang.String",
Types.VARCHAR, true, true,
AttributeDef.UPDATEABLE, (byte)7);
String  voName="DynamicVO";
OAViewObject vo = (OAViewObject) findViewObject(voName);
if (vo != null)
{ vo.remove();
System.out.println("VO removed: " + voName);
}
vo = (OAViewObject) createViewObject(voName, viewDef);
}







public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)throws OAException
  {
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
if ("Go".equals(pageContext.getParameter(EVENT_PARAM)))
         {
           DataObject fileUploadData = (DataObject)pageContext.getNamedDataObject("FileUploadItem");
           String fileName = null;
           String contentType = null;
           Long fileSize = null;
           Integer fileType = new Integer(6);
           BlobDomain uploadedByteStream = null;
           BufferedReader in = null;
   try
           {
             fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
             contentType = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
             uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, fileName);
             in =  new BufferedReader(new InputStreamReader(uploadedByteStream.getBinaryStream()));
fileSize = new Long(uploadedByteStream.getLength());
             System.out.println("fileSize  : " + fileSize);
             System.out.println("fileName :"+fileName);
             System.out.println("contentType :"+contentType);
           }
catch (NullPointerException ex)
           {
             throw new OAException("Please Select a File to Upload",OAException.ERROR);
           }


 
 The below are the BC4J components which work in OAF
 ENTITY OBJECT:
• The entity objects are used if one wishes to do some insert/update operations.
• Entity Objects represents a Data Base Row of a table.
• Entity Objects will be based on the View (Oracle View), Synonyms or snapshots.
• We need to create Entity Object if we want to perform DML operations on the OAF Page.
VIEW OBJECT :
• View Objects are used when we want some data to be displayed on page.
• View Objects access the result set of a SQL statement, it can be either based on the Entity Object or plain SQL query.
• View Objects are used just for displaying purpose.
APPLICATION MODULE:
• It is very important component in the Model.
• Every Oracle Application Framework (OAF) page should be attached to some Application Module.
• It is the interface between the Client transactions and Data Base transactions.
















    OAApplicationModule am=pageContext.getApplicationModule(webBean);
   
    if (pageContext.getParameter("Apply") != null)
       {
        OAViewObject vo = (OAViewObject)am.findViewObject("DepartmentEO");
        String column1 = (String)vo.getCurrentRow().getAttribute("Dept_ID");
        String column2 = (String)vo.getCurrentRow().getAttribute("Dept_Name");
       // String column3 = (String)vo.getCurrentRow().getAttribute("Description");
        am.invokeMethod("save");
       }
   
    if (pageContext.getParameter("AddRow") != null)
     {  
   
     am.invokeMethod("CreateEmployeeRow",null);
     }







   
    public void CreateEmployeeRow()
    {
       EmployeeEOVOImpl vo = getEmployeeEOVO1();

       Row row = vo.createRow();
       vo.insertRow(row);
       row.setNewRowState(Row.STATUS_INITIALIZED);
    }
    public void save()
    {
      getTransaction().commit();
    }

Comments

Popular posts from this blog

OAF Registration

Java Excel