Tuesday, 16 December 2014



THE ORACLE ADF ARCHITECTURE
Oracle ADF is based on the Model-View-Controller (MVC) design pattern. An MVC application is separated into: 1) a model layer that handles interaction with data-sources and runs the business logic, 2) a view layer that handles the application user interface, and 3) a controller that manages the application flow and acts as the interface between the Model and the View layers.
Separating applications into these three layers simplifies maintenance and reuse of components across applications. The independence of each layer from the others results in a loosely coupled, Service Oriented Architecture (SOA).
Oracle ADF implements MVC and further separates the model layer from the business services to enable service-oriented development of applications. The Oracle ADF architecture is based on four layers:
The Business Services layer - provides access to data from various sources and handles business logic.
--> The Model layer - provides an abstraction layer on top of the Business Services layer, enabling the View and Controller layers to work with different implementations of Business Services in a consistent way.
--> The Controller layer - provides a mechanism to control the flow of the Web application.
--> The View layer - provides the user interface of the application.


Oracle ADF lets developers choose the technology they prefer to use when implementing each of the layers. The diagram above shows the various options available for developers when building Oracle ADF applications. The glue that integrates the various components of Java EE applications and makes development so flexible is the Oracle ADF model layer. EJB, Web Services, JavaBeans, JPA/EclipseLink/TopLink objects and many others can all be used as Business Services for the Oracle ADF Model. View layers can include Web based interfaces implemented with JSF, Desktop Swing applications and MS Office front ends, as well as interfaces for mobile devices.


Creating dependednt picklist in OAF:

1)Create a VO with bind parameters.
2)In process request method get the item bean in to veriable.
3)set the properties like below mentioned:
OAMessageChoiceBean itemId=
(OAMessageChoiceBean)table.findChildRecursive("test");
itemId.setPickListCacheEnabled(false);
itemId.setListVOBoundContainerColumn(0,table(tableBean Id),"TableItemId")

Copy Functinality in OAF and ADF:(This functionality same in OAF and ADF)

To copy selected line first we need to get the line into row type.

Row selectedRows[] = vo.getFilteredRows("selected", "Y");
if(selectedRows.length >0){// Check lines are selected or not
for (int a = 0; a < manRows.length; a++) { SelectedVORowImpl copyrow = (SelectedVORowImpl)selectedRows[a]; for (int k = 0; k < a; k++) { Row newrow = vo.createRow(); try {//Dynamically setting value newrow.setAttribute(k,copyrow.getAttribute(k))); } catch (Exception e) { Row errorrow = errorVO.createRow(); errorrow.setAttribute(0,fileName); errorrow.setAttribute(1,t-1); errorrow.setAttribute(2,e.getMessage().toString()); removeRow="Y"; break; } vo.insertRow(newrow); } } }

Tuesday, 9 September 2014

Hi Friends,

I got a requirement to undo the changes of a perticuler row if user changed something :

Row CururrentRow=vo.getCurrentRow();

currentRow.refresh(currentRow.REFRESH_UNDO_CHANGES|currentRow.REFRESH_WITH_DB_FORGET_CHANGES);

Using above code we can refresh the changes.

Tuesday, 26 August 2014




Using inner query

select a.cycle_id, a.cycle_duration, a.cycle_name,
a.financial_year, a.active_flag, (
select max (last_update_date) from XXGLO_APPLIED_REIMBURSEMENTS b
where a.cycle_id= b.cycle_id and
a.cycle_duration=b.cycle_duration
--created_by= fnd_profile.value('USER_ID')
and fnd_global.user_id=created_by
) last_update_date,
decode(a.active_flag,'Y','Y1','N1') active_flag1
from XXGLO_FIN_CYCLES a
order by financial_year desc



Thursday, 31 July 2014

Using array list in OAF:
Most of the java requierements we need define arralist:

ArrayList parameters = new ArrayList(4);
parameters.add(lprogId);

Wednesday, 30 July 2014


Difference Between getAllRowsInRange and getRowAtRangeIndex

We can retrieve the rows in several methods

Example 1
oracle.jbo.Row rows[] = getdataVo.getAllRowsInRange();
for (int i = 0; i < rows.Lengthi++) { GetsomeVORowImpl someVORow = (GetsomeVORowImpl )rows(i); } Example 2 for (int i = 0; i < getDataVo.getRowCount(); i++) { GetsomeVORowImpl someVORow = (GetsomeVORowImpl )GetsomeVO.getRowAtRangeIndex(i); }


when to use ADF and when to use OAF


The Integration of the custom bolt-on or Extensions we want to maintain tightly with E-Business Suite we should use the OAF Release 12 technology stack(which uses J developer 10g) or OAF Release 11 technology stack(which uses J developer 9i)
If your application does not need to integrate with the E-Business suite or doesn't require any of the E-Business suite-specific capabilities enumerated like Flex fields and personalization you should use ADF 10g with SOA based integration with E-Business Suite.
If you are building a separate Application that does not integrate tightly with the E-Business suite, but needs E-Business Suite-specific capabilities like Flex fields and personalization, you should use the OAF Release 12 technology stack
If you are building a separate application that does not need to integrate at all with the E-Business Suite and you need an AJAX-style rich client user interface you should use ADF 11g.


Thursday, 10 July 2014

Change the font into upper case:

CSSStyle ora = new CSSStyle();

ora.setProperty("text-transform", "uppercase");

OAMessageTextInputBean Serial=(OAMessageTextInputBean)webBean.findChildRecursive("Serial");
Serial.setInlineStyle(ora);


Getting person id from userId:

select papf.PERSON_ID,papf.LAST_NAME
from fnd_user fu
,per_all_people_f papf
where fu.USER_ID=:usid
and fu.EMPLOYEE_ID=papf.PERSON_ID
and trunc(sysdate) between trunc(papf.EFFECTIVE_START_DATE) and trunc(papf.EFFECTIVE_END_DATE)

Tuesday, 15 April 2014

Formating Number:

oracle.cabu.ui.validate.Formatter formatter =
new OADecimalValidater("###0.###;-###0.###","#.##0.###;-#,##0.###");
bean.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);

Monday, 14 April 2014

Upper Case:       

       
CSSStyle ora = new CSSStyle();        
        ora.setProperty("text-transform", "uppercase");        
        OAMessageTextInputBean Serial=(OAMessageTextInputBean)webBean.findChildRecursive("Serial");        
        Serial.setInlineStyle(ora);

Wednesday, 26 February 2014

Genarating CSV File from OAF:

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.io.FileWriter;




if("printErrors".equals(pageContext.getParameter(EVENT_PARAM))){
try

{
System.out.println("printErrors1");
String csv = "D:\\output.csv";
FileWriter writer = new FileWriter(csv);
Connection conn = am.getOADBTransaction().getJdbcConnection();

String Query = "select attribute1,attribute2,attribute3 from  XXX_ERROR_TBL";

PreparedStatement stmt = conn.prepareStatement(Query);
writer.append("File Name");
writer.append(',');
writer.append("Row Number");
writer.append(',');
writer.append("Error Message");
writer.append('\n');

for(ResultSet resultset = stmt.executeQuery(); resultset.next();)
{
pageContext.writeDiagnostics(this, "Query Executed", 1);
String result = resultset.getString("attribute1");
String result1 = resultset.getString("attribute2");
String result2 = resultset.getString("attribute3");
System.out.println("results are "+result);
System.out.println("results1 are "+result1);
System.out.println("results2 are "+result2);
writer.append(result);
writer.append(',');
writer.append(result1);
writer.append(',');
writer.append(result2);
writer.append('\n');

}
writer.flush();
writer.close();

}

catch(Exception exception)

{
throw new OAException("Error in Staffing Query"+exception, OAException.ERROR);
}

}//close if printErrors

// End writing CSV




How to Read CSV and insert Errors in Table dynamically:

if (pageContext.getParameter("uploadItm") != null) {
DataObject fileUploadData =
(DataObject)pageContext.getNamedDataObject("uploadFileItm2");
String fileName = null;
String contentType = null;
Long fileSize = null;
Integer fileType = new Integer(6);
BlobDomain uploadedByteStream = null;
BufferedReader in = null;
long count = 0;
long errorCount = 0;
String fileId=am.getOADBTransaction().getSequenceValue("gConItem_fileID_SEQ").toString();
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);
} catch (NullPointerException ex) {
throw new OAException("Please Select a File to Upload",
OAException.ERROR);
}


try {


//Open the CSV file for reading
String lineReader = "";
long t = 0;
int z = 1;
String removeRow="N";
String[] linetext;

while (((lineReader = in.readLine()) != null)) {

//Split the deliminated data and
if (lineReader.trim().length() > 0) {

linetext = lineReader.split(",");
t++;
count=t;
if (t > 1) {

//Print the current line being
int a = linetext.length;
// System.out.println("line text length is : "+a);
Row arrow = arvo.createRow();
// need to enable after altering table
// arrow.setAttribute("FileId",fileId);
removeRow="N";
for (int k = 0; k < a; k++)
{
try {
arrow.setAttribute(k,linetext[k].toString());
}
catch (Exception e)
{ //inserting errors in error table dynamically
Row errorrow = errorVO.createRow();
errorrow.setAttribute(0,fileName);
errorrow.setAttribute(1,t);
errorrow.setAttribute(2,e.getMessage().toString());
removeRow="Y";
break; }
//System.out.println("line number"+t+"and cloumn"+k);
// System.out.println(linetext[k]);
// arrow.setAttribute(k, linetext[k]);
}
if (removeRow.equalsIgnoreCase("N"))
{ arvo.insertRow(arrow);
}else{ arrow.remove(); errorCount++;
} z++;
if (z % 10000 == 0) am.getOADBTransaction().commit();
}
// System.out.println("record"+t);
}
// need to save records here
}
System.out.println("end time");
}
catch (IOException e)
{
throw new OAException(e.getMessage(), OAException.ERROR);
}
configId=pageContext.getParameter("configHeaderIdFV").toString();
String convItm=pageContext.getParameter("convertionItemFV").toString();
String ou=pageContext.getParameter("ouIdFv").toString();
String invOrg=null;
if(pageContext.getParameter("invOrgIdFV")!=null)
{ invOrg= pageContext.getParameter("invOrgIdFV").toString();}
System.out.println(pageContext.getParameter("configHeaderIdFV").toString()+"--"+pageContext.getParameter ("convertionItemFV").toString());
count=count-errorCount-1;
AM.addFilesDetails(configId,convItm,count,errorCount,fileName,ou,invOrg,fileId); }// end upload functionality


Tuesday, 25 February 2014


How to set read only property based on Value

in Query: decode(GConConfigLinesEO.RULE_TYPE,'STD','true','false') readonly

Create atribute in VO:

And set SPEL in Read Only Property:${oa.GConConfigLinesVO1.Readonly}
Uploading a file to perticuler location in server from Local mechine:


in PFR :
if(pageContext.getParameter("go")!=null){
upLoadFile( pageContext, webBean) ;
}
Now Wirite a custom method to upload file.

import below classes:

import java.io.File;
import java.io.FileOutputStream;
import oracle.jbo.domain.BlobDomain;
import java.io.InputStream;
import oracle.cabo.ui.data.DataObject;
import oracle.apps.fnd.framework.OAException;

public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
{ String filePath = "/oracle/DEV/apps/apps_st/appl/xxsea/12.0.0/data";
System.out.println("Default File Path---->"+filePath);

String fileUrl = null;
try
{
DataObject fileUploadData = pageContext.getNamedDataObject("MessageFileUpload");

//FileUploading is my MessageFileUpload Bean Id
if(fileUploadData!=null)
{
String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
System.out.println("User File Name---->"+uFileName);

FileOutputStream output = null;
InputStream input = null;

BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
System.out.println("uploadedByteStream---->"+uploadedByteStream);

File file = new File("/oracle/DEV/apps/apps_st/appl/xxsea/12.0.0/data", uFileName);
System.out.println("File output---->"+file);

output = new FileOutputStream(file);

System.out.println("output----->"+output);
input = uploadedByteStream.getInputStream();

System.out.println("input---->"+input);
byte abyte0[] = new byte[0x19000];
int i;

while((i = input.read(abyte0)) > 0)
output.write(abyte0, 0, i);

output.close();
input.close();
}
}
catch(Exception ex)
{
throw new OAException(ex.getMessage(), OAException.ERROR);
} }

Calling Cuncorent Program from OAF Page.

In Application Module Create a custom method as below:
import below statements:


import java.util.Vector;
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.cp.request.RequestSubmissionException;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.Row;

// method to submit the cp
public int submitCPRequest(Number headerId) {

try {

OADBTransaction tx = (OADBTransaction)getDBTransaction();
java.sql.Connection pConncection = tx.getJdbcConnection();
ConcurrentRequest cr = new ConcurrentRequest(pConncection);

String applnName = "PO"; //Application that contains the concurrent program
String cpName = "POXCONST"; //Concurrent program name
String cpDesc = "Contract Status Report"; // concurrent Program description

// Pass the Arguments using vector
// Here i have added my parameter headerId to the vector and passed the vector to the concurrent program

Vector cpArgs = new Vector();
//cpArgs.addElement(headerId.toString());


// Calling the Concurrent Program

int requestId = cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs);
tx.commit();

return requestId;

} catch (RequestSubmissionException e) {
OAException oe = new OAException(e.getMessage());
oe.setApplicationModule(this);
throw oe;

}
}

// end method to submit cp

//Calling above method
public int submitConcurrent Program(){

int reqid=submitCPRequest(1);
System.out.println("reqid"+reqid);
return reqid;

}


Monday, 17 February 2014

How to deployee OAF pages into Instaces

We can import OAF pages in two process:
1)From Jdev:
go to cmd prompt and change the directry to cd p6908968_R12_GENERIC\jdevbin\oaext\bin.
and run below command (before running please change the details).

example:
import D:\OAF\jdevhome\jdev\myprojects\test\oracle\apps\geogont\shopfloor\webui\test.xml -rootdir D:\OAF\jdevhome\jdev\myprojects -username apps -password welcomed1 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=))(CONNECT_DATA=(SID=)))"

2)Using linux:

Move the files into $JAVA_TOP/ and run the below example

java oracle.jrad.tools.xml.importer.XMLImporter $JAVA_TOP/xxmb/oracle/apps/xxcicms/contest/definition/webui/test.xml -rootdir $JAVA_TOP -username apps -password cmnewapps2013 -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=))(CONNECT_DATA=(SID=)))"


Friday, 14 February 2014

setting alert in OAF




StringBuffer l_buffer = new StringBuffer();
String convertionType;
l_buffer.append("javascript:alert('"+convertionType+"')");
pageContext.putJavaScriptFunction("Name",l_buffer.toString());

Tuesday, 28 January 2014

Uploading a CSV file into Data Base Table using OAF

Hi Friends,

Today i am going to share how to upload a CSV file into Data Base table in OAF.

1)Create an item type: MessageFileUpload and change the itemid.It will give us a browse option for file.

2)Create a button for uploading event.Here i am using normal button and updated event as Go.

3)In controller Process form request we need to handle Go event.

Before that please import below classes:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.cabo.ui.data.DataObject;
import oracle.jbo.domain.BlobDomain;
------------------

in Process for request :
------------------


    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);
      }

      try
      {
        //Open the CSV file for reading
        String lineReader = "";
        long t = 0;
        String[] linetext;
        while (((lineReader = in.readLine()) != null))
        {
          //Split the deliminated data and
          if (lineReader.trim().length() > 0)
          {
            System.out.println("lineReader" + lineReader.length());
            linetext = lineReader.split(",");
            t++;
           int a= linetext.length;
           System.out.println("line text length is : "+a);
           for(int k=0;k<a;k++){
          
           System.out.println(linetext[k]);
           }
}
// Now Create a new row in respective View Object and set the attributes and Save the transaction.


Wednesday, 8 January 2014

How to set Max and Min dates for calendar  value:


Handle this in Process request:

try
      {
     
      PreparedStatement prpdStmt1=am.getOADBTransaction().getJdbcConnection().prepareStatement("select NVL(TO_DATE (fnd_profile.VALUE ('GLOBAL_DATE'),'DD-MON-RRRR'),SYSDATE) date1 FROM DUAL");
     
      ResultSet rs=prpdStmt1.executeQuery();
      rs.next();
         
      java.sql.Date date1 = rs.getDate("date1");
          PreparedStatement prpdStmt12=am.getOADBTransaction().getJdbcConnection().prepareStatement("select NVL(TO_DATE (fnd_profile.VALUE ('GLOBAL_DATE'),'DD-MON-RRRR'),SYSDATE+60) date1 FROM DUAL");
         
          ResultSet rs1=prpdStmt12.executeQuery();
          rs1.next();
             
          java.sql.Date date12 = rs1.getDate("date1");
         
     
     
        OAMessageDateFieldBean dateField = (OAMessageDateFieldBean)webBean.findIndexedChildRecursive("stdate");
System.out.println("date1----"+date1);
          System.out.println("date12----"+date12);
       dateField.setMinValue(date1);
          dateField.setMaxValue(date12);
     
      }
      catch(Exception e)
      {
   
      }