Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Hello,
In this tutorial, OAF Table Region DML operations will be implemented.
We will cover the following topics:
Fetching rows from database table and display them on table region
LAST_UPDATED_BY: The NUMBER column that shows which FND_USERUSER_ID updated the row
1
2 create table hr.xx_oaf_anil_personel (
3
person_id
number,
4
first_name
varchar2(120),
5
last_name
varchar2(120),
6
salary
number,
7
date_of_birth
date,
8
hire_date
date,
9
created_by
number,
1
creation_date
date,
0
last_update_date
date,
1
last_updated_by
number,
1
last_update_login
number
1 );
2
1
3
1
4
1
5
1
6
1
7
1 alter table hr.xx_oaf_anil_personel
8 add constraint xx_oaf_anil_personel_pk primary key (person_id);
1
9
2 create public synonym xx_oaf_anil_personel for hr.xx_oaf_anil_personel;
0
2 create sequence hr.xx_oaf_anil_personel_s
1 start with 1
2 increment by 1
2 minvalue 1
2 nocache
3 nocycle
2 noorder;
4
2
5
2
6
2
7
2
8
2
9
1.Open JDeveloper. Right click to your project and select New.
10. After business componenets will be created, the strcuture for packages look like following:
11. Right click to project and select New. Under Web Tier menu
select OA Componenets sub-menu. Select Page object and click Ok button.
13. Give proper ID to pageLayoutRegion. Give proper titles to Window Title and Title
attributes nde pageLayoutRegion. Set AM Definition by selecting your application module.
17. Create a header region under pageLayoutRegion. Right click to PageLayoutRN and select
New Region. Set Region Type as Header. Give proper ID and text values.
18. Create an advanced table under header region.
REGION STYLE
ID
VIEW INSTANCE
WIDTH
advancedTable
DmlAdvanceTableRN
XxOafAnilPersonelEOVO1
100%
19. Add 5 columns under advanced table by right clicking to DmlAdvanceTableRN and select
New -> Column.
20. Create 5 column headers under 5 columns.
21. At this step, the page structure should be look like this:
22. Give proper ID and prompt values to columns and column headers.
column1
ID: FirstNameCol
sortableHeader1
ID: FirstNameColHdr
Prompt: First Name
column2 ID: LastNameCol
sortableHeader2
ID: LastNameColHdr
Prompt: Last Name
column3
ID: SalaryCol
sortableHeader3
ID: SalaryColHdr
Prompt: Salary
column4
ID: DateOfBirthCol
sortableHeader4
ID: DateOfBirthColHdr
Prompt: Date of Birth
column5
ID: HireDateCol
sortableHeader5
ID: HireDateColHdr
Prompt: Hire Date
23. At this step, the page structure should be look like this:
messageTextInput items under columns.
24. Create
FirstNameCol->New->Item
ID
ITEM STYLE
DATA TYPE
MAXIMUM LENGTH
VIEW ATTRIBUTE
FirstName
messageTextInput
VARCHAR2
120
FirstName
LastNameCol->New->Item
ID
ITEM STYLE
DATA TYPE
MAXIMUM LENGTH
VIEW ATTRIBUTE
LastName
messageTextInput
VARCHAR2
120
LastName
SalaryCol->New->Item
ID
ITEM STYLE
DATA TYPE
Salary
messageTextInput
NUMBER
DateOfBirthCol->New->Item
MAXIMUM LENGTH
VIEW ATTRIBUTE
Salary
ID
ITEM STYLE
DATA TYPE
DateOfBirth
messageTextInput
DATE
MAXIMUM LENGTH
VIEW ATTRIBUTE
DateOfBirth
HireDateCol->New->Item
ID
ITEM STYLE
DATA TYPE
HireDate
messageTextInput
DATE
MAXIMUM LENGTH
VIEW ATTRIBUTE
HireDate
25. At this step, the page structure should be look like this:
26.In order to display table data on page load, SQL query in View Object must be executed.
Open the controller java file which is created in step 16. Controller objects have 2 methods.
These are:
Java
1
2 public void initQuery() {
3
executeQuery();
4 }
5
Open application module impl java file.
Add the following method into application module implementation java file. This method will
check the vo is null or not and then call the initQuery method in view object implementation file.
executeOafAnilPersonelVO
Java
1
2 public void executeOafAnilPersonelVO() {
3
XxOafAnilPersonelEOVOImpl vo = getXxOafAnilPersonelEOVO1();
4
if (vo == null) {
5
throw new OAException("Error: XxOafAnilPersonelEOVOImpl is null");
6
}
7
vo.initQuery();
8 }
9
Open controller object again and add the following code in processRequest method.
processRequest
Java
1
2
3 {
4
super.processRequest(pageContext, webBean);
5
//get application module object from the context by sending webBean. webBean
6 object represents pageLayoutRegion because controller object is attached to it.
7
OAApplicationModule am = pageContext.getApplicationModule(webBean);
8
//call application module method
9
am.invokeMethod("executeOafAnilPersonelVO");
1 }
0
27. Run the page and test it. Table will be empty since no rows are added into database table.
Add Row
1. Create tableActions into the advanced table region. Right click to DmlAdvanceTableRN and
select New -> tableActions. Change flowLayout region ID to a proper name.
2. Right click to
TableActionsRN and select New->Item. Change Item properties with following:
ID
ITEM STLE
PROMPT
ACTION TYPE
EVENT
AddNewRow
button
firePartialAction
addNewRow
the wizard will be closed. This will overwirte create method in entity object java file. This
method will be called whenever a row is created. Initial attribute values can be set in this
method. In this tutorial, primary key of table will be set with a number value which will be
fetched from a database sequence object.
1
2
3
/**Add attribute defaulting logic in this method.
4
*/
5
public void create(AttributeList attributeList) {
6
super.create(attributeList);
7
//get transaction
8
OADBTransactionImpl transaction =
9 (OADBTransactionImpl)getOADBTransaction();
1
//get next value from sequence in transaction
0
Number PersonId =
1 transaction.getSequenceValue("HR.XX_OAF_ANIL_PERSONEL_S");
1
//set it to primary key
1
setPersonId(PersonId);
2
}
1
3
5. Open application module java file and create addNewRow method.
addNewRow
Java
1
2
3
4
public void addNewRow() {
5
//Find view object from application module
6
OAViewObject vo = (OAViewObject)getXxOafAnilPersonelEOVO1();
7
//unless vo query is executed or if no row has inserted before, setMaxFetchSize
8
to 0
9
if (vo.getFetchedRowCount() == 0) {
1
vo.setMaxFetchSize(0);
0
}
1
//create a row object from view object. At this point execution will jump to entity
1
object create method
1
Row row = vo.createRow();
2
//insert row into view object
1
vo.insertRow(row);
3
//in order to keep row state, set it as initialized.
1
row.setNewRowState(Row.STATUS_INITIALIZED);
4
}
1
5
1
6
6. Open controller object java file and write following code in processFormRequest method.
processFormRequest
Java
1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
7. Up to this point, all these operations take action on front end. In OAF, transaction
management is handled by application module. One application module represents one
transaction. When a transaction is ended with commit or rollback, all of the updatable view
objects (view object which is derived from entity object) pass transaction data to the entity
object and prepared statements are executed by OAF in order to insert data into table and
commit or rollback the transaction. In order to end transaction, we need a submit button in the
page.
8. Right click to pageLayoutRegion and select New->Region. Change the region properties with
the followings:
ID
REGION STYLE
PageButtonBarRN
pageButtonBar
Right click to pageButtonBar and select New->Item. Change the Item properties with the
followings:
ID
ITEM STYLE
PROMPT
Apply
submitButton
Kaydet
1
2 public void apply() {
3
getOADBTransaction().commit();
4 }
5
10. Open controller object java file and change processFormRequest method with the following.
processFormRequest
Java
1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
xx_oaf_anil_personel
Oracle PL/SQL
1
2 select * from xx_oaf_anil_personel;
3
Results:
1
2
public void removeSelectedRows() {
3
//Find view object in application module
4
OAViewObject vo = (OAViewObject)getXxOafAnilPersonelEOVO1();
5
//create a row list
6
java.util.List<Row> removeList = new ArrayList<Row>();
7
//get the row count from view object
8
int rowCount = vo.getFetchedRowCount();
9
if (rowCount > 0) {
1
//create a row object from voRowImpl class.
0
XxOafAnilPersonelEOVORowImpl row = null;
1
//Create a RowSetIterator from view object. Set it start as 0 and range as
1 rowCount
1
RowSetIterator iter = vo.createRowSetIterator("Iter");
2
iter.setRangeStart(0);
1
iter.setRangeSize(rowCount);
3
for (int i = 0; i < rowCount; i++) {
1
row = (XxOafAnilPersonelEOVORowImpl)iter.getRowAtRangeIndex(i);
4
1
5
1
6
1
7
1
8
1
9
2
0
if (row != null) {
2
//check whether row is selected or not. If selected, add it to the list.
1
if ("Y".equals(row.getSelectedRow())) {
2
removeList.add(row);
2
}
2
}
3
}
2
//always close row set iterator
4
iter.closeRowSetIterator();
2
5
//remove rows one by one
2
for (Row deleteRow : removeList) {
6
deleteRow.remove();
2
}
7
2
}
8
}
2
9
3
0
3
1
3
2
3
3
3
4
3
5
Not: Please pay attention to iterator usage. You can move between view object
rows with vo.next method. However it will change the current row in view object
and that is not a thing we always want.
9.Open the page structure and add a button under TableActionsRN. Set the following values:
ID
ITEM STLE
PROMPT
ACTION TYPE
EVENT
DeleteSelectedRows
button
firePartialAction
deleteSelectedRows
10. Open controller object java file and change processFormRequest method with the following
code.
processFormRequest
Java
1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
1
6
This tutorial covers many basic and important topics in OAF. I hope it will prove some useful
information for EBS developers.
Regards,
Anil
Tags: oracle apps, oracle, oaf, oa framework, oaf table, advanced table, row selection, entity
object, application module,add row, view object
2- Stored Function
public void testFunction() {
OADBTransaction txn = getDBTransaction();
CallableStatement callableStatement =
txn.createCallableStatement("begin :1 := xx_function(:2);
end;",OADBTransaction.DEFAULT);
try {
callableStatement.registerOutParameter(1, Types.VARCHAR);
callableStatement.setString(1, "mahmoud");
String outParamValue = null;
callableStatement.execute();
outParamValue = callableStatement.getString(1);
callableStatement.close();
} catch (SQLException sqle) {
}
callableStatement.close();
ocs.setString(1, s_struc_code);
ocs.setARRAY(2, segval);
ocs.setString(3, v_person_id);
ocs.setString(4, v_emp_id);
ocs.registerOutParameter(5, 12);
ocs.execute();
v_message = ocs.getString(5);
ocs.close();
}
catch(SQLException sqlexception)
{
throw new OAException("Error " + sqlexception.getMessage(), (byte)2);
}
==========================
public voic initEmpFuncVO(String deptnoStr)
{
EmpfuncVOIMPL vo=getEmpFuncVO1();
vo.clearcache();
vo.setWhereClause(null);
vo.setWhererClauseParam(0,deptnoStr);
vo.executeQuery();
}
public void deleteEmpRow()
{
Empvoimpl vo=getempvo1();
EmpVORowImpl row=null;
Row rows[]=vo.getFilteredRows("SelectedFlag","Y");
for(int i=0;i<rows.length;i++)
{
row=(EmpVORowImpl)rows(i);
String sql="BEGIN xxcus_oaf_emp_utils.delete_emp(p_emp_id=>:1); END;";
CallableStatement
cstmt=getOADBTransaction().createCallableStatement(sql,1);
try
{
cstmt.setInt(1,row.getEmpno().intValue());
cstmt.execute();
cstmt.close();
}catch(SQLException e) {
//TODO
}
row.remove();
} //loop end
getOADBTransaction().commit();
throw new OAException("Deleted the sel rows",OAException.CONFORMATION);
}
==================================================
=========================
In Process Request
OAPopupBean popupBean
=(OAPopupBean)createWebBean(pageContext,POPUP_BEAN,null,"myPopup");
//Set the following properties on the pop-up:
popupBean.setID("myPopup");
popupBean.setUINodeName("myPopup");
String popupRegion=
"/oracle/apps/fnd/framework/toolbox/labsolutions/webui/TestEmpDetailsRN" ;
popupBean.setRegion(popupRegion);
popupBean.setHeight("130");
popupBean.setWidth("320");
popupBean.setTitle("Test");
popupBean.setType(EMBEDDED_POPUP); /* Embedded type */
Step 1:
Create EO Based VO i.e,EMPVO
SELECT EMPEo.EMPNO,
EMPEo.ENAME,
EMPEo.JOB,
EMPEo.MGR,
EMPEo.HIREDATE,
EMPEo.SAL,
EMPEo.COMM,
EMPEo.DEPTNO,
EMPEo.CREATION_DATE,
EMPEo.CREATED_BY,
EMPEo.LAST_UPDATE_DATE,
EMPEo.LAST_UPDATE_LOGIN,
EMPEo.LAST_UPDATED_BY,
EMPEo.ROWID,DECODE (EMPEo.JOB
,'MANAGER', '1','2'
) color
FROM EMP EMPEo
Step 2:Under Custom.xss
add Follwing code
<style name="For_Bold">
<property name="font-weight">bold</property>
<property name="font-size">10pt</property>
</style>
<style selector=".1">
<includeStyle name="DefaultFamily"/>
<property name="font-size">11pt</property>
<property name="font-weight">Bolder</property>
<property name="color">#FFFF00</property>
<property name="text-indent">3px</property>
<property name="background-color">#FF0000</property>
</style>
<style selector=".2">
<includeStyle name="DefaultFontFamily"/>
<property name="font-size">11pt</property>
<property name="font-weight">Bolder</property>
<property name="color">#FFFF00</property>
<property name="text-indent">3px</property>
<property name="background-color">#003399</property>
</style>
pw.write("\n");
// getting table data
Row row2=null;
System.out.println(row1.length);
for(int i=0;i<row1.length;i++)//Read Selected Rows
{
row2=row1[i];
String dept_name= row2.getAttribute("Empno").toString();
String emp_name=row2.getAttribute("Ename").toString();
String Salary=row2.getAttribute("Sal").toString();
if(dept_name !=null) // for null handling in the code
{
pw.write(dept_name);
}
else
{
pw.write(" ");
}
//
emp_name = emp_name.replaceAll(",",".");
pw.write(",");
if(emp_name!=null)
{
pw.write(emp_name);
}
else
{
pw.write("");
}
pw.write(",");//next cell
if(Salary!=null)
{
pw.write(Salary);
}
else
{
pw.write("");
}
pw.write("\n");//next line
}
pw.write(" ");
pageContext.setDocumentRendered(false); //mandatory
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.server.OAViewObjectImpl;
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.Row;
import oracle.jbo.domain.BlobDomain;
/**
* Controller for ...
*/
public class FileUploadCO 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
/**
* 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=(OAApplicationModule)pageContext.getApplicationModule(webBean);
OAViewObjectImpl vo = (OAViewObjectImpl) am.findViewObject("DemoVO1");
if (pageContext.getParameter("Go")!=null)
{
DataObject fileUploadData
=(DataObject)pageContext.getNamedDataObject("FileUploadItem");
String fileName = null;
String contentType = null;
Long fileSize = 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()));
long t =0;
String[] linetext;
if (!vo.isPreparedForExecution()) {
vo.setMaxFetchSize(0);
vo.executeQuery();
}
Row row = vo.createRow();
System.out.println("Column1->"+linetext[0]);
row.setAttribute("VendorName", linetext[0]);
row.setAttribute("Segment1",linetext[1]);
row.setAttribute("VendorId",linetext[2]);
vo.last();
vo.next();
vo.insertRow(row);
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
if ("update".equals(pageContext.getParameter(EVENT_PARAM))) {
am.getOADBTransaction().commit();
throw new OAException("Uploaded SuccessFully",OAException.CONFIRMATION);
}
}
}
java oracle.jrad.tools.xml.importer.XMLImporter
$JAVA_TOP/xxmhp/oracle/apps/per/loan/webui/TestPG.xml --rootdir $JAVA_TOP
username <user name> -password <password> -dbconnection
"(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<hostname>)(PORT=<port
number>))(CONNECT_DATA=(SID=<SID>)))"