You are on page 1of 270

2013

www.AppsLead.com
Oracle Applications Framework Business Cases

Cell phone 002/010 900 160 23

Prepared By: Mostafa El-Roby

We guide you to the right path


in Oracle Applications

AppsLead for Consultation and Training


January 16th , 2013
Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OAF Hello World Tutorial

Create OAF Search Page

Create Auto Customization Criteria OAF Search Page

Clear/ Reset Result Table of Search page in OAF

Create Data Entry OAF Page

Update Records in OAF Page

Create and Update on one click in OA Framework

Delete records in OAF Page

Implement Master Detail Relationship in OAF Page

Working with Key Flex Fields in OAF

Implement Dependent LOV in OAF

Implement External LOV in OAF

Set default Value for messageTextInput item

Implement PopList in OA Framework

Partial Page Rendering in OAF

Execute parameterized PL SQL procedure from OAF page

Implement Train in OAF Page

D2k to OAF Transformation

Call D2K Form from OAF Page

Call OAF Page From D2K Form

Get Host Name and URL of OAF Page

OAF Page to Upload Files into Server from Local Machine

Deploy JAR File into R12 in OA Server

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Import Data from Excel sheet to DB Table

Import Data from *.xlsx file to DB Table

Deploy OAF page

Bounce Apache Server

Enable Personalization Link for OAF Pages

Enable Personalization Link for OAF Pages

Deploy JAR File into R12 in OA Server

Controller Extension in OAF

Application Module Extension in OAF

EO based VO Extension in OAF

Entity Object Extension in OAF

OA Framework Best Practices

OAException Message and Dialog Page in OA Framework

Deploying OAF Personalizations Using the Import/Export Command Line Tools

Best Blog :-

1- http://iwidi.org/index.php/oaf

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Basic Installation Steps -

1. Download JDeveloper 10.1.3.3.0. Available Oracle patch is p8431482_R12_GENERIC.zip


Unzip the patch p8431482_R12_GENERIC.zip i.e. in D:\

2. Specify the path of jdev in following location


My Computer>Properties>Advanced>Environment Variables as given below screen shot

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Download dbc file of Oracle application instance from $FND_TOP/secure


( it is like a tnsnames.ora file having connection detail )
Place the file at location D:\p8431482_R12_GENERIC\jdevhome\jdev\dbc_files\secure

4. Open JDeveloper and set database connection goto Connection Navigator > Database and
create a new connection

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Note Give user name and password do not give any role and do not check Deploy
Password checkbox

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Note Give Host Name, JDBC port, and SID. Keep driver as thin.

Now JDeveloper is ready to use

5. Create a sample workspace and project to know setting during creation of project

1. Goto Application Navigator right click > New > General > Workspace Configured
for Oracle Applications

2. Give workspace name

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Give project name and Default package

Note Default package is


<3rd party identifier>.oracle.apps.<application_short_name>.<component>.
[<subcomponent>]
Example: mycompany.oracle.apps.po.requisition.webui

4. Give database connection detail

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Give your dbc file location, application username, application password,


application short name, and responsibility key
i.e. Application short key and responsibility key is nothing but assigned
responsibility detail to the application user for example if application user has
System Administrator responsibility then Application short name will be
“SYSADMIN” and responsibility key will be “SYSTEM_ADMINISTRATOR”.
These values are required to compile and run the page because page required
context during run time so it will login the application with given username and
password and it will take context from assigned responsibility

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

6. Click Next. Creation of Workspace and project has finished

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OAF Hello World Tutorial


1. Create a New OA Workspace and Empty OA Project
File> New > General> Workspace Configured for Oracle Applications

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

2. Set Run Options in OA Project Setting


Select Your Project in the Navigator and choose Project Properties
Select Oracle Applications > Run Options
Select OADeveloperMode and OADiagnostic, and move them to selected Options List

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Create Application Module AM

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

4. Create a OA components Page

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Modify the Page Layout (Top-level) Region

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID PageLayoutRN

Region Style pageLayout

Form Property True

Auto Footer True

Window Title Hello World Window Title

Title Hello World Page Header

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

AM Definition prajkumar.oracle.apps.ak.hello.server.HelloAM

6. Create the Second Region (Main Content Region)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID MainRN

Region Style messageComponentLayout

7. Create the first Item (Empty Field)


MainRN > New > messageTextInput

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID HelloName

Style Property messageTextInput

Prompt Name

Length 20

Maximum Length 50

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

8. Create a container Region for Go-Button


MainRN > messageLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID ButtonLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

9. Create a Second Item (Go Button)


Select ButtonLayout > New > Item

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID Go

Item Style submitButton

Attribute /oracle/apps/fnd/attributesets/Buttons/Go

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

10. Save Your Work

11. Run Your Page UI is ready

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

12. Add a Controller


MainRN > Set New Controller

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

13. Edit Your Controller


Add Following OA Exception as a last line in import section
import oracle.apps.fnd.framework.OAException;
Add Following Code in processFormRequest
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

super.processFormRequest(pageContext, webBean);

if (pageContext.getParameter("Go") != null)

String userContent = pageContext.getParameter("HelloName");

String message = "Hello, " + userContent + "!";

throw new OAException(message, OAException.INFORMATION);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

14. Build Your Controller

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

15. Test Your Work Your Hello World Page is Ready

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Create OAF Search Page


1. Create a New Workspace and Project
Right click Workspaces and click create new OAworkspace and name it as PRajkumarSearch.
Automatically a new OA Project is also created. Name the project as SearchDemo and package
as prajkumar.oracle.apps.fnd.searchdemo

2. Create a New Application Module (AM)


Right Click on SearchDemo > New > ADF Business Components > Application Module
Name -- SearchAM
Package -- prajkumar.oracle.apps.fnd.searchdemo.server

3. Enable Passivation for the Root UI Application Module (AM)


Right Click on SearchAM > Edit SearchAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK

4. Create Test Table and insert data some data in it (For Testing Purpose)
CREATE TABLE xx_search_demo
( -- --------------------
-- Data Columns
-- --------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
-- --------------------
-- Who Columns
-- --------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);
INSERT INTO xx_search_demo VALUES („val1‟, ‟val2‟, SYSDATE, 0, SYSDATE, 0, 0);
INSERT INTO xx_search_demo VALUES („val1‟, ‟val2‟, SYSDATE, 0, SYSDATE, 0, 0);
INSERT INTO xx_search_demo VALUES („val3‟, ‟val4‟, SYSDATE, 0, SYSDATE, 0, 0);
INSERT INTO xx_search_demo VALUES („val5‟, ‟val6‟, SYSDATE, 0, SYSDATE, 0, 0);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Now we have 4 records in our custom table

5. Create a New Entity Object (EO)


Right click on SearchDemo > New > ADF Business Components > Entity Object
Name – SearchEO
Package -- prajkumar.oracle.apps.fnd.searchdemo.schema.server
Database Objects -- XX_SEARCH_DEMO

Note – By default ROWID will be the primary key if we will not make any column to be
primary key Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on SearchDemo > New > ADF Business Components > View Object
Name -- SearchVO
Package -- prajkumar.oracle.apps.fnd.searchdemo.server
In Step2 in Entity Page select SearchEO and shuttle them to selected list
In Step3 in Attributes Window select columns Column1, Column2 and shuttle them to
selected list
In Java page Select Generate Java file for View Object Class: SearchVOImpl and Generate Java
File for View Row Class: SearchVORowImpl

7. Add Your View Object to Root UI Application Module


Select Right click on SearchAM > Edit SearchAM > Data Model >
Select SearchVO and shuttle to Data Model list

8. Create a New Page


Right click on SearchDemo > New > Web Tier > OA Components > Page
Name -- SearchPG
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

9. Select the SearchPG and go to the strcuture pane where a default region has been created

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

10. Select region1 and set the following properties:


ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM
Window Title -- Search Page Window
Title -- Search Page
Auto Footer -- True

11. Add a Query Bean to Your Page


Right click on PageLayoutRN > New > Region
Select new region region1 and set following properties
ID – QueryRN
Region Style – query
Construction Mode – resultBasedSearch
Include Simple Panel – True
Include Views Panel – True
Include Advanced Panel – True

12. Add a Result Data Table to your QueryRN


Select QueryRN right click > New > Region using Wizard
In BC4J Objects page, Select your SearchAM and then select your SearchVO1

Note – DO NOT select Use this as Application Module Definition for this region checkbox

In Region Properties page, set Region ID value to ResultsTable and Region Style to table
In view Attributes page, select attributes from Available View Attributes list and shuttle
them to
Selected View Atributes list:
Column1
Column2

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

In Region Items Page, you can set ID, Style and Attributes Set. Currently we are going to set
only Style as messageStyledText

13. Set and verify Your Results Table Region Properties


ID – ResultsTable
Region Style – table
AM – Please Donot put any AM
Rendered – True
Records Displayed – 10
Width – 100%
User Personalization – True

14. Set or Verify Column1 Item Properties


Search Allowed -- True
Sort Allowed – ascending
Initial Sort Seqence – first
Selective Search Criteria – True
User Personalization – True

15. Set or Verify Column2 Item Properties


Search Allowed – True
Sort Allowed -- ascending
Selective Search Criteria – True
User Personalization – True

16. Congratulation you have successfully finished Search page. Run Your SearchPG page
and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Create Auto Customization Criteria OAF Search Page


1. Create a New Workspace and Project
Right click Workspaces and click create new OAworkspace and name it as
PRajkumarCustSearch. Automatically a new OA Project will also be created. Name the project
as CustSearchDemo and package as prajkumar.oracle.apps.fnd.custsearchdemo

2. Create a New Application Module (AM)


Right Click on CustSearchDemo > New > ADF Business Components > Application Module
Name -- CustSearchAM
Package -- prajkumar.oracle.apps.fnd.custsearchdemo.server

3. Enable Passivation for the Root UI Application Module (AM)


Right Click on CustSearchAM > Edit SearchAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK

4. Create Test Table and insert data some data in it (For Testing Purpose)

CREATE TABLE xx_custsearch_demo


( -- ---------------------
-- Data Columns
-- ---------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
column3 VARCHAR2(100),
column4 VARCHAR2(100),
-- ---------------------
-- Who Columns
-- ---------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

INSERT INTO xx_custsearch_demo VALUES('v1','v2','v3','v4',SYSDATE,0,SYSDATE,0,0);


INSERT INTO xx_custsearch_demo VALUES('v1','v3','v4','v5',SYSDATE,0,SYSDATE,0,0);
INSERT INTO xx_custsearch_demo VALUES('v2','v3','v4','v5',SYSDATE,0,SYSDATE,0,0);
INSERT INTO xx_custsearch_demo VALUES('v3','v4','v5','v6',SYSDATE,0,SYSDATE,0,0);
Now we have 4 records in our custom table

5. Create a New Entity Object (EO)


Right click on SearchDemo > New > ADF Business Components > Entity Object
Name – CustSearchEO
Package -- prajkumar.oracle.apps.fnd.custsearchdemo.schema.server
Database Objects -- XX_CUSTSEARCH_DEMO

Note – By default ROWID will be the primary key if we will not make any column to be
primary key

Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on CustSearchDemo > New > ADF Business Components > View Object
Name -- CustSearchVO
Package -- prajkumar.oracle.apps.fnd.custsearchdemo.server

In Step2 in Entity Page select CustSearchEO and shuttle them to selected list

In Step3 in Attributes Window select columns Column1, Column2, Column3, Column4, and
shuttle them to selected list

In Java page deselect Generate Java file for View Object Class: CustSearchVOImpl and Select
Generate Java File for View Row Class: CustSearchVORowImpl

7. Add Your View Object to Root UI Application Module

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Select Right click on CustSearchAM > Application Modules > Data Model
Select CustSearchVO and shuttle to Data Model list

8. Create a New Page


Right click on CustSearchDemo > New > Web Tier > OA Components > Page
Name -- CustSearchPG
Package -- prajkumar.oracle.apps.fnd.custsearchdemo.webui

9. Select the CustSearchPG and go to the strcuture pane where a default region has been
created

10. Select region1 and set the following properties:


ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.custsearchdemo.server.CustSearchAM
Window Title – AutoCustomize Search Page Window
Title – AutoCustomization Search Page
Auto Footer -- True

11. Add a Query Bean to Your Page


Right click on PageLayoutRN > New > Region
Select new region region1 and set following properties
ID – QueryRN
Region Style – query
Construction Mode – autoCustomizationCriteria
Include Simple Panel – False
Include Views Panel – False
Include Advanced Panel – False

12. Create a New Region of style table

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Right Click on QueryRN > New > Region Using Wizard

Application Module – prajkumar.oracle.apps.fnd.custsearchdemo.server.CustSearchAM


Available View Usages – CustSearchVO1

In Step2 in Region Properties set following properties


Region ID – CustSearchTable
Region Style – Table

In Step3 in View Attributes shuttle all the items (Column1, Column2, Column3, Column4)
available in “Available View Attributes” to Selected View Attributes:
In Step4 in Region Items page set style to “messageStyledText” for all items

13. Select CustSearchTable in Structure Panel and set property Width to 100%

14. Include Simple Search Panel


Right Click on QueryRN > New > simpleSearchPanel
Automatically region2 (header Region) and region1 (MessageComponentLayout Region)
created

Set Following Properties for region2


Id – SimpleSearchHeader
Text -- Simple Search

15. Now right click on message Component Layout Region (SimpleSearchMappings) and
create two message text input beans and set the below properties to each

Message TextInputBean1
Id – SearchColumn1
Search Allowed – True
Data Type – VARCHAR2
Maximum Length –
CSS Class – OraFieldText

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Prompt – Column1

Message TextInputBean2
Id – SearchColumn2
Search Allowed -- True
Data Type – VARCHAR2
Maximum Length – 100
CSS Class – OraFieldText
Prompt – Column2

16. Now Right Click on query Components and create simple Search Mappings. Then
automatically SimpleSearchMappings and QueryCriteriaMap1 created

17. Now select the QueryCriteriaMap1 and set the below properties
Id – SearchColumn1Map
Search Item – SearchColumn1
Result Item – Column1

18. Now again right click on simpleSearchMappings -> New -> queryCriteriaMap, and then
set the below properties
Id – SearchColumn2Map
Search Item – SearchColumn2
Result Item – Column2

19. Congratulation you have successfully finished Auto Customization Search page. Run
Your CustSearchPG page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Clear/ Reset Result Table of Search page in OAF


Normally problem faced by developers after creating Search Page is how to Clear/ Reset
Result Table when developer open search page first time or after search when developer
redirecting back to same search page from any other page (say delete page or update page)

Add following Code in your Search page Controller where you have constructed your Query
Region

import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
...
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
// Here QueryRN is your Query Region Name as shown in following snap shot
queryBean.clearSearchPersistenceCache(pageContext);
}

Note –
After add this code, no need to worry about state of Application Module (AM). This code will
clean up result table automatically every time when you will open Search page first time and
when you are redirecting back to search page. But still as per good coding standard while
redirecting back to search page always keep AM state to FALSE

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Create Data Entry OAF Page


By PRajkumar on Apr 22, 2012

1. Create a New Workspace and Project


Right click Workspaces and click create new OAworkspace and name it as PRajkumarInsert.
Automatically a new OA Project is also created. Name the project as InsertDemo and package
as prajkumar.oracle.apps.fnd.insertdemo

2. Create a New Application Module (AM)


Right Click on InsertDemo > New > ADF Business Components > Application Module
Name -- InsertAM
Package -- prajkumar.oracle.apps.fnd.insertdemo.server

3. Enable Passivation for the Root UI Application Module (AM)


Right Click on InsertAM > Edit InsertAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK

4. Create Test Table in which we will insert data (For Testing Purpose)
CREATE TABLE xx_insert_demo
( -- ---------------------
-- Data Columns
-- ---------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
-- ---------------------
-- Who Columns
-- ---------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

5. Create a New Entity Object (EO)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Right click on InsertDemo > New > ADF Business Components > Entity Object
Name – InsertEO
Package -- prajkumar.oracle.apps.fnd.insertdemo.schema.server
Database Objects -- XX_INSERT_DEMO

Note – By default ROWID will be the primary key if we will not make any column to be
primary key.
Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on InsertDemo > New > ADF Business Components > View Object
Name -- InsertVO
Package -- prajkumar.oracle.apps.fnd.insertdemo.server
In Step2 in Entity Page select InsertEO and shuttle them to selected list
In Step3 in Attributes Window select columns Column1, Column2 and shuttle them to
selected list
In Java page deselect Generate Java file for View Object Class: InsertVOImpl and Select
Generate Java File for View Row Class: InsertVORowImpl

7. Add Your View Object to Root UI Application Module


Right click on InsertAM > Edit InsertAM > Data Model >
Select InsertVO in Available View Objects list and shuttle to Data Model list

8. Create a New Page


Right click on InsertDemo > New > Web Tier > OA Components > Page
Name -- InsertPG
Package -- prajkumar.oracle.apps.fnd.insertdemo.webui

9. Select the InsertPG and go to the strcuture pane where a default region has been created

10. Select region1 and set the following properties:

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.insertdemo.server.InsertAM
Window Title -- Date Entry Page Window
Title -- Data Entry Page
Auto Footer -- True

11. Right click PageLayoutRN > New > Region


ID -- MainRN
Region Style -- defaultSingleColumn

12. Create Text Input Items


Right click on MainRN > New > Item
Set following properties for New Item
ID -- COLUMN1
Item Style -- messageTextInput
Maximum Length -- 100
Length -- 20
Prompt -- Column1
View Instance -- InsertVO1
View Attribute -- Column1

Again Right click on MainRN > New > Item


Set following properties for New Item
ID -- COLUMN2
Item Style -- messageTextInput
Maximum Length -- 100
Length -- 20
Prompt -- Column2
View Instance -- InsertVO1

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

View Attribute – Column2

13. Add Apply and Cancel Buttons


Right click on PageLayoutRN > New > Region
ID -- PageButtons
Region Style -- pageButtonBar

Right click on PageButtons > New > Item


ID -- Cancel
Item Style -- submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Cancel
Disable Server Side Validation -- True
Prompt -- Cancel
Warm About Changes -- False
Additional Text – Select to cancel this transaction.

Right click on PageButtons > New > Item


ID -- Apply
Item Style -- submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Apply
Prompt -- Apply
Additional Text – Select to save this transaction.

14. Implement Row Initialization (Create a View Object Row)


Add createRecord method to your InsertAMImpl class
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
...

public void createRecord()


{
OAViewObject vo = (OAViewObject)getInsertVO1();

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}

Row row = vo.createRow();


vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
}

15. Create Controller for Page


PageLayoutRN > Set New Controller >
Package Name: prajkumar.oracle.apps.fnd.insertdemo.webui
Class Name: InsertCO

16. Add Create Page Initialization to your Controller


Add following code to your processRequest()
import oracle.apps.fnd.framework.OAApplicationModule;
...

public void processRequest(OAPageContext pageContext,OAWebBean webBean)


{
super.processRequest(pageContext, webBean);

if (!pageContext.isFormSubmission())
{
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("createRecord", null);
}
}

17. Add below method in InsertAMImpl Class to handle Apply Button action
import oracle.jbo.Transaction;
...

public void apply()


{
getTransaction().commit();
}

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

18. Add below Logic in InsertCO to handle Apply Button


Add following code to your processFormRequest()
import oracle.jbo.domain.Number;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
...

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

{super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

// Pressing the "Apply" button means the transaction should be


// validated and committed.

if (pageContext.getParameter("Apply") != null)
{
OAViewObject vo = (OAViewObject)am.findViewObject("InsertVO1");

String column1 = (String)vo.getCurrentRow().getAttribute("Column1");


String column2 = (String)vo.getCurrentRow().getAttribute("Column2");

am.invokeMethod("apply");

// Create a FND Message with name "TEST_CREATE_CONFIRM" with two


// tokens
MessageToken[] tokens = { new MessageToken("COLUMN1", column1),
new MessageToken("COLUMN2", column2)
};

OAException confirmMessage = new OAException( "FND",


"TEST_CREATE_CONFIRM", tokens,
OAException.CONFIRMATION, null);

pageContext.putDialogMessage(confirmMessage);
pageContext.forwardImmediately(
"OA.jsp?page=/prajkumar/oracle/apps/fnd/insertdemo/webui/InsertPG",
null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

19. Congratulations you have successfully created data insert page. Run InsertPG page to
test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Update records in OAF Page

1. Create a Search Page to Create a page please go through the following link
https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page

2. Implement Update Action in SearchPG


Right click on ResultTable in SearchPG > New > Item

Set following properties for New Item

Attribute Property

ID UpdateAction

Item Style image

Image URI updateicon_enabled.gif

Atribute Set /oracle/apps/fnd/attributesets/Buttons/Update

Prompt Update

Additional Text Update record

Height 24

Width 24

Action Type fireAction

Event update

Submit True

Parameters Name – PColumn1


Value -- ${oa.SearchVO1.Column1}
Name – PColumn2
Value -- ${oa.SearchVO1.Column2}

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Create a Update Page


Right click on SearchDemo > New > Web Tier > OA Components > Page
Name – UpdatePG
Package – prajkumar.oracle.apps.fnd.searchdemo.webui

4. Select the UpdatePG and go to the strcuture pane where a default region has been created

5. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

Region Style PageLayout

AM Definition prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM

Window Title Update Page Window

Title Update Page

Auto Footer True

6. Create the Second Region (Main Content Region)


Select PageLayoutRN right click > New > Region
ID – MainRN
Region Style – messageComponentLayout

7. Create first Item (Empty Field)


MainRN > New > messageTextInput

Attribute Property

ID Column1

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Style Property messageTextInput

Prompt Column1

Data Type VARCHAR2

Length 20

Maximum Length 100

View Instance SearchVO1

View Attribute Column1

8. Create second Item (Empty Field)


MainRN > New > messageTextInput

Attribute Property

ID Column2

Style Property messageTextInput

Prompt Column2

Data Type VARCHAR2

Length 20

Maximum Length 100

View Instance SearchVO1

View Attribute Column2

9. Create a container Region for Apply and Cancel Button in UpdatePG


Select MainRN of UpdatePG
MainRN > messageLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

Region ButtonLayout

10. Create Apply Button


Select ButtonLayout > New > Item

Attribute Property

ID Apply

Item Style submitButton

Attribute /oracle/apps/fnd/attributesets/Buttons/Apply

11. Create Cancel Button


Select ButtonLayout > New > Item

Attribute Property

ID Cancel

Item Style submitButton

Attribute /oracle/apps/fnd/attributesets/Buttons/Cancel

12. Add Page Controller for SearchPG


Right Click on PageLayoutRN of SearchPG > Set New Controller
Name – SearchCO
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

Add Following code in Search Page controller SearchCO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
queryBean.clearSearchPersistenceCache(pageContext);
}

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processFormRequest(pageContext, webBean);

if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
{
pageContext.setForwardURL("OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/we
bui/UpdatePG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}
13. Add Page Controller for UpdatePG
Right Click on PageLayoutRN of UpdatePG > Set New Controller
Name – UpdateCO
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

Add Following code in Update Page controller UpdateCO

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

{
super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String Column1 = pageContext.getParameter("PColumn1");
String Column2 = pageContext.getParameter("PColumn2");
Serializable[] params = { Column1, Column2 };
am.invokeMethod("updateRow", params);
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

if (pageContext.getParameter("Apply") != null)
{
am.invokeMethod("apply");
pageContext.forwardImmediately("OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdem
o/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdem
o/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}

14. Add following Code in SearchAMImpl

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

public void updateRow(String Column1, String Column2)


{
SearchVOImpl vo = (SearchVOImpl)getSearchVO1();
vo.initQuery(Column1, Column2);
}

public void apply()


{
getTransaction().commit();
}
public void rollback()
{
getTransaction().rollback();
}

15. Add following Code in SearchVOImpl

import oracle.apps.fnd.framework.server.OAViewObjectImpl;

public void initQuery(String Column1, String Column2)


{
if ((Column1 != null) && (!("".equals(Column1.trim()))))
{
setWhereClause("column1 = :1 AND column2 = :2");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, Column1);
setWhereClauseParam(1, Column2);
executeQuery();
}
}

16. Congratulation you have successfully finished. Run Your Search page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Create and Update on one click in OA Framework


We will try to implement Search Page with one text item as ID. Based on ID control
will go to second page. Second page contain three text rows. ID will be displayed on
second page as Styled Text in all three rows
If match will be found based on ID then search result will come. If not found then
empty rows will come. Based on that new data can be inserted there and existing data
can be updated directly with one button click „Apply‟

1. Create a New Workspace and Project


Right click Workspaces and click create new OAworkspace.
File Name – PrajkumarSearch
Project Name -- SearchDemo
package -- prajkumar.oracle.apps.fnd.searchdemo

2. Create a New Application Module (AM)


Right Click on SearchDemo > New > ADF Business Components > Application Module
Name -- SearchAM
Package -- prajkumar.oracle.apps.fnd.searchdemo.server

3. Enable Passivation for the Root UI Application Module (AM)


Right Click on SearchAM > Edit SearchAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK

4. Create Test Table and insert data some data in it (For Testing Purpose)
CREATE TABLE xx_create_upd_demo
( -- ---------------------
-- Data Columns
-- ----------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
column3 VARCHAR2(100),
column4 NUMBER,

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

-- ---------------------
-- Who Columns
-- ---------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

5. Create a New Entity Object (EO)


Right click on SearchDemo > New > ADF Business Components > Entity Object
Name – SearchEO
Package -- prajkumar.oracle.apps.fnd.searchdemo.schema.server
Database Objects -- xx_create_upd_demo

Note – By default ROWID will be the primary key if we will not make any column to be
primary key.
Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on SearchDemo > New > ADF Business Components > View Object
Name -- SearchVO
Package -- prajkumar.oracle.apps.fnd.searchdemo.server
In Step2 in Entity Page select SearchEO and shuttle them to selected list
In Step3 in Attributes Window select columns Column1, Column2, Column3, Column4 and
shuttle them to selected list
In Java page select Generate Java File for View Object Class: SearchVOImpl and Generate Java
File for View Row Class: SearchVORowImpl

7. Add Your View Object to Root UI Application Module


Select Right click on SearchAM > Application Modules > Data Model >
Select SearchVO and shuttle to Data Model list

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

8. Create a New Page


Right click on SearchDemo > New > Web Tier > OA Components > Page
Name -- SearchPG
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

9. Select the SearchPG and go to the strcuture pane where a default region has been created

10. Select region1 and set the following properties:


ID – PageLayoutRN
Scope -- Public
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM
Window Title –Page Window
Title – Page Header
Auto Footer – True

11. Create the Second Region (Main Content Region)


ID – MainRN
Region Style -- messageComponentLayout
Auto Footer – True

12. Create the first Item (Empty Field)


MainRN > New > messageTextInput
Set Following properties for new item
ID – MyId
Style Property – messageTextInput
Prompt – Id
Data Type – Number
Length – 20
Maximum Length – 100

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

13. Create a container Region for Go-Button


MainRN > messageLayout
Set ID -- ButtonLayout

14. Create a Item (Go Button)


Select ButtonLayout > New > Item
ID – Go
Item Style – submitButton
Attribute -- /oracle/apps/fnd/attributesets/Buttons/Go

15. Create a New Second Page


Right click on SearchDemo > New > Web Tier > OA Components > Page
Name -- CreateUpdPG
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

16. Select the CreateUpdPG and go to the strcuture pane where a default region has been
created

17. Select region1 and set the following properties:


ID – PageLayoutRN
Scope -- Public
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchAM
Window Title –Page Window
Title – Page Header
Auto Footer – True

18. Create the Second Region (Main Content Region)


ID – MainRN
Region Style -- table

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Auto Footer – True


Records Displayed – 3

19. Create the first Item (Empty Field)


MainRN > New > item
Set Following properties for new item
ID – Column1
Style Property – messageTextInput
Prompt – Column1
Data Type – VARCHAR2
Length – 20
Maximum Length – 100
View Instance -- SearchVO1
View Attribute -- Column1

Create Second Item


MainRN > New > item
Set Following properties for new item
ID – Column2
Style Property – messageTextInput
Prompt – Column2
Data Type – VARCHAR2
Length – 20
Maximum Length – 100
View Instance -- SearchVO1
View Attribute -- Column2

Create Third Item


MainRN > New > item
Set Following properties for new item

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID – Column3
Style Property – messageTextInput
Prompt – Column3
Data Type – VARCHAR2
Length – 20
Maximum Length – 100
View Instance -- SearchVO1
View Attribute -- Column3

Create Fourth Item


MainRN > New > item
Set Following properties for new item
ID – Column4
Style Property – messageStyledText
Prompt – Column4
Data Type – NUMBER
View Instance -- SearchVO1
View Attribute -- Column4

20. Add Controller for Page SearchPG Select PageLayoutRN right click Set New
Controller
Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui

Class Name -- SearchCO


Add Following code in that controller

import com.sun.java.util.collections.HashMap;

import oracle.apps.fnd.framework.webui.OAWebBeanConstants;

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processFormRequest(pageContext, webBean);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

if (pageContext.getParameter("Go") != null)
{
String userContent = pageContext.getParameter("MyId");
HashMap hmap = new HashMap();
hmap.put("MyId", userContent);

pageContext.setForwardURL(
"OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/CreateUpdPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
hmap,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}

21. Add Return Link to come back to SearchPG from CreateUpdPG


Select CreateUpdPG in Structure Panel Select PageLayoutRN > New > returnNavigation
ID – ReturnLink

Destination URI –
OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/SearchPG&retainAM=Y
Text – Return to SearchPG

22. Add pageButtonBar region to implement Apply Button


Right click on PageLayout > New > Region
Set following properties for new region
ID -- ButtonBar
Region Style – pageButtonBar
Select ButtonBar right click > New > Item
Select newly created item and set following properties –
ID – Apply
Item Style – submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Apply

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

23. Add Controller for Page CreateUpdPG Select PageLayoutRN right click Set New
Controller
Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui
Class Name -- CreateUpdCO
Add Following code in that controller

import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{ super.processRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

String val = pageContext.getParameter("MyId");

Serializable[] params = { val };


am.invokeMethod("createRow", params);
}

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)


{ super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);

if (pageContext.getParameter("Apply") != null)
{ am.getTransaction().commit();
pageContext.setForwardURL(
"OA.jsp?page=/prajkumar/oracle/apps/fnd/searchdemo/webui/SearchPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true,
OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
OAWebBeanConstants.IGNORE_MESSAGES);
}
}

24. Add Following code in SearchAMImpl.java

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.Row;
public void createRow(String Val)
{
SearchVOImpl vo = getSearchVO1();
vo.initQuery(Val);

int rowCount = vo.getRowCount();


if ( rowCount < 3 )
{
for(int i = 3; i != rowCount ; rowCount++)
{
Row studrow = vo.createRow();
vo.last();
vo.next();

vo.insertRow(studrow);
vo.setCurrentRow(studrow);
vo.getCurrentRow().setAttribute("Column4",Val);
studrow.setNewRowState(Row.STATUS_INITIALIZED);
}
}
}

25. Add Following code in SearchVOImpl.java

import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
public void initQuery(String Val)
{
if ((Val != null) && (!("".equals(Val.trim()))))
{
// Do the following conversion for type consistency.
Number Val2 = null;

try
{

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Val2 = new Number(Val);


}
catch(Exception e)
{
throw new OAException("AK", "FWK_TBX_INVALID_EMP_NUMBER");
}

setWhereClause("Column4 = :1");
setWhereClauseParams(null); // Always reset
setWhereClauseParam(0, Val2);
executeQuery();
}
}

26. Congratulation you have successfully finished. Run Your SearcgPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Delete Records in OAF Page


1. Create a Search Page to Create a page please go through the following link
https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page

2. Implement a Delete in your SearchEOImpl Class


public void remove()
{ super.remove();
} // end remove()

3. Create a Delete Image


Select ResultsTable right click > New > Item
Set following properties for New Item
ID – DeleteAction
Item Style – image
Image URI – deleteicon_enabled.gif
Atribute Set -- /oracle/apps/fnd/attributesets/Buttons/Delete
Prompt -- Delete
Additional Text – Delete record action enabled
Height – 24
Width – 24
Action Type – fireAction
Event – delete
Submit – True
Select Parameter Properties define parameter name as Column1 and whose value is
${oa.SearchVO1.Column1}
Select Parameter Properties define parameter name as Column2 and whose value is
${oa.SearchVO1.Column2}
Select OK button to create your request parameters

4. Add Page Controller


Add a New Contoller for SearchPG

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Name – SearchCO
Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

Implement Delete Action


5. Add deleteRecord() method to SearchAMImpl
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.RowSetIterator;
...
public void deleteRecord(String Column1)
{ OAViewObject vo = (OAViewObject)getSearchVO1();
SearchVORowImpl row = null;
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
{ deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedRowCount);
for (int i = 0; i < fetchedRowCount; i++)
{
row = (SearchVORowImpl)deleteIter.getRowAtRangeIndex(i);
row.remove();
getTransaction().commit();
break;
}
}
deleteIter.closeRowSetIterator();
} // end deleteRecord

Note – Create Standard FND Messages DELETE_RECORD_WARN and


DELETE_CONFIRM

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

6. Add DeleteSelection Handler Code to SearchCO.processFormRequest()


import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAApplicationModule;
...
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject vo =(OAViewObject)am.findViewObject("SearchVO1");
String rowRef =
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
OARow row = (OARow)am.findRowByRef(rowRef);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
{
String Column1 = (String)row.getAttribute("Column1");
String Column2 = (String)row.getAttribute("Column2");
String Column3 = pageContext.getParameter("Column1");
String Column4 = pageContext.getParameter("Column2");
MessageToken[] tokens = { new MessageToken("COLUMN1", Column1),
new MessageToken("COLUMN2", Column2)};

OAException mainMessage = new OAException("FND",


"DELETE_RECORD_WARN", tokens);
OADialogPage dialogPage = new OADialogPage(OAException.WARNING,
mainMessage, null, "", "");
String yes = pageContext.getMessage("AK", "FWK_TBX_T_YES", null);
String no = pageContext.getMessage("AK", "FWK_TBX_T_NO", null);

dialogPage.setOkButtonItemName("DeleteYesButton");
dialogPage.setOkButtonToPost(true);
dialogPage.setNoButtonToPost(true);
dialogPage.setPostToCallingPage(true);

dialogPage.setOkButtonLabel(yes);
dialogPage.setNoButtonLabel(no);
java.util.Hashtable formParams = new java.util.Hashtable(1);
formParams.put("Column1", Column3);
formParams.put("Column2", Column4);
dialogPage.setFormParameters(formParams);

pageContext.redirectToDialogPage(dialogPage);
}

7. Add Delete Confirmation Handler Code to SearchCO.processFormRequest()


import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
...
else if (pageContext.getParameter("DeleteYesButton") != null)
{
String Column1 = (String)row.getAttribute("Column1");
String Column2 = (String)row.getAttribute("Column2");
Serializable[] parameters = { Column1 };

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OAApplicationModule am =
pageContext.getApplicationModule(webBean);
am.invokeMethod("deleteRecord", parameters);
OAException message = new OAException("FND",
"DELETE_CONFIRM", null,
OAException.CONFIRMATION, null);
pageContext.putDialogMessage(message);
}

8. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Implement Master Detail Relationship in OAF Page


Let us try to implement Master Detail Relationship in advanceedTable. We will create two
tables master table and child table. Both have relationship with each other with Column1

(Note - Column1 is a primary key in both tables)

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- MasterDetailProj
Project Name – MasterDetailDemo
Default Package -- prajkumar.oracle.apps.fnd.masterdetaildemo

2. Create Application Module AM


MasterDetailDemo right click > New > ADF Business Components > Application Module
Name -- MasterdetailDemoAM
Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server
Check Generate JavaFile(s)

3. We need two tables one table will be act as Master table and second table will be
act as Child or detail table. Lets Create two tables
-- Master Table
CREATE TABLE master_table_demo
( -- ---------------------
-- Data Columns
-- ---------------------
Column1 VARCHAR2(100),
Column2 VARCHAR2(100),
-- ----------------------
-- Who Columns
-- ----------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

last_update_login NUMBER
);

-- Detail Table
CREATE TABLE detail_table_demo
( -- ---------------------
-- Data Columns
-- ---------------------
Column1 VARCHAR2(100),
Column2 VARCHAR2(100),
-- ----------------------
-- Who Columns
-- ----------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

Note – Consider Master Table is Linked to Detail Table with Column1

4. Lets put some data in the tables


-- Insert Data into Master Table
INSERT INTO master_table_demo VALUES ( „VAL1‟, „VAL2‟, SYSDATE, 0, SYSDATE, 0, 0);
INSERT INTO master_table_demo VALUES ( „VAL3‟, „VAL4‟, SYSDATE, 0, SYSDATE, 0, 0);

-- Insert Data into Detail Table


INSERT INTO detail_table_demo VALUES ( „VAL1‟, „VAL6‟, SYSDATE, 0, SYSDATE, 0, 0);

INSERT INTO detail_table_demo VALUES ( „VAL3‟, „VAL8‟, SYSDATE, 0, SYSDATE, 0, 0);

5. Create a New Entity Object (EO) for Master Table


Right click on MasterDetailDemo > New > ADF Business Components > Entity Object
Name – MasterEO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.schema.server
Database Objects -- master_table_demo

Note -- Make Column1 as a primary key

Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New Entity Object (EO) for Detail Table


Right click on MasterDetailDemo > New > ADF Business Components > Entity Object
Name – DetailEO
Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.schema.server
Database Objects -- detail_table_demo

Note -- Make Column1 as a primary key

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Check the Accessors, Create Method, Validation Method and Remove Method

Note – Column1 in both tables is common Column to make parent child


relationship

7. Lets Create View Object for Master Table


Right click on MasterDetailDemo > New > ADF Business Components > View Object
Name -- MasterVO
Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server
In Step2 in Entity Page select MasterEO and shuttle them to selected list
Create transient item by clicking on New
Name – DetailFlag
Type -- Boolean

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

In Step3 in Attributes Window select columns Column1, Column2, DetailFlag and shuttle
them to selected list
In Java page deselect Generate Java file for View Object Class: MasterVOImpl

8. Lets Create View Object for Detail Table


Right click on MasterDetailDemo > New > ADF Business Components > View Object
Name -- DetailVO
Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server
In Step2 in Entity Page select DetailEO and shuttle them to selected list
In Step3 in Attributes Window select columns Column1, Column2 and shuttle them to
selected list
In Java page deselect Generate Java file for View Object Class: DetailVOImpl

9. Create View Link Add Your View Object to Root UI Application Module
Right click on MasterDetailDemo > New > ADF Business Components > View Link
Name – MasterdetailDemoVL

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server

10. Add Your View Object to Root UI Application Module


Right click on MasterdetailDemoAM > Application Modules > Data Model >
Select MasterVO, DetailVO via ViewLink, DetailVO and shuttle to Data Model list

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

11. Create a New Page


Right click on MasterdetailDemo > New > Web Tier > OA Components > Page
Name -- MasterdetailDemoPG
Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.webui

12. Select MasterdetailDemoPG and go to the strcuture pane where a default region has
been created

13. Select region1 and set the following properties:


ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- prajkumar.oracle.apps.fnd.masterdetaildemo.server.MasterdetailDemoAM

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Window Title – Master Detail Demo Page Window


Title – Master Detail Demo Page Header
Auto Footer – True

14. Add a New Region MainRN


Select PageLayoutRN right click > New > Region
ID -- MainRN
Region Style – header

15. Create a Master Table Region


Select MainRN > New > Region
ID – MainTableRN
Region Style -- advancedTable
View Instance -- MasterVO1
Detail View Attribute – DetailFlag
Child View Attribute -- Column1
View Link Instance -- MasterdetailDemoVL1
Width – 100%
Rendered – True

16. Create Columns and their items for MainTableRN


Create Column1
Select MainTableRN > New > column
Select column1 > New > Item
ID – item1
Item Style – messageStyledText
View Attribute – Column1

Create Column2
Select MainTableRN > New > column

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Select column2 > New > Item


ID – item2
Item Style – messageStyledText
View Attribute – Column2

17. Create a Detail Region


Select MainTableRN > New > detail
A new Region will be get created under detail set following properties for that region
ID – DetailRN
Region Style – header

18. Create a DetailTable Region


Select DetailRN > New > Region
For New region set following Properties
ID – DetailTableRN
Region Style – advancedTable
View Instance -- DetailVO2
View Link Instance -- MasterdetailDemoVL1
Width – 100%
Rendered – True

19. Create Columns and their items for DetailTableRN


Create Column3
Select DetailTableRN > New > column
Select column3 > New > Item
ID – item3
Item Style – messageStyledText
View Instance – DetailVO2
View Attribute – Column1

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Create Column4
Select DetailTableRN > New > column
Select column4 > New > Item
ID – item4
Item Style – messageStyledText
View Instance – DetailVO2
View Attribute – Column2

20. Add Controller for Page MasterdetailDemoPG Select PageLayoutRN right click Set
New Controller
Package Name -- prajkumar.oracle.apps.fnd.masterdetaildemo.webui
Class Name -- MasterdetailDemoCO
Set Following Code in CO

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import prajkumar.oracle.apps.fnd.masterdetaildemo.server.MasterdetailDemoAMImpl;
...
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
MasterdetailDemoAMImpl AM =
(MasterdetailDemoAMImpl)pageContext.getApplicationModule(webBean);
pageContext.writeDiagnostics(this, "Calling Method", 1);
AM.MasterDetails(pageContext,webBean);
}

21. Add Following Code in your AMImpl Class (MasterdetailDemoAMImpl.java)

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
...
public void MasterDetails(OAPageContext pageContext,OAWebBean webBean)
{

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

MasterVOImpl pvo = getMasterVO1();


pvo.executeQuery();
}
22. Final Structure pane will look like following picture

23. Congratulation you have successfully finished. Run Your MasterdetailDemoPG page
and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Key Flex Fields, KFF in OAF


1. Create a New Workspace and Project
Right click Workspaces and click create New OA Workspace and name it as
PRajkumarKFFDemo. Automatically a new OA Project will also be created. Name the project
as KFFDemo and package as prajkumar.oracle.apps.fnd.kffdemo

2. Create a New Application Module (AM)


Right Click on KFFDemo > New > ADF Business Components > Application Module
Name -- KFFAM
Package -- prajkumar.oracle.apps.fnd.kffdemo.server

Check Application Module Class: KFFAMImpl Generate JavaFile(s)

3. Create a New View Object (VO)


Right click on KFFDemo > New > ADF Business Components > View Object
Name -- KFFVO
Package -- prajkumar.oracle.apps.fnd.kffdemo.server

Note - The VO is not based on any EO so click next and go to the query section and paste the
query

SELECT code_combination_id
FROM gl_code_combinations_kfv

In Step8 Check Object Class: KFFVOImpl -> Generate Java File -> Bind Variable Accessors

4. Add View Object to Root UI Application Module


Right Click on KFFAM > Edit KFFAM > Data Model and shuttle KFFVO from Available
View Objects to Data Model

5. Create a New Page


Right click on KFFDemo > New > Web Tier > OA Components > Page

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Name -- KFFPG
Package -- prajkumar.oracle.apps.fnd.kffdemo.webui

6. Select the KFFPG and go to the strcuture pane where a default region has been created

7. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

AM Definition prajkumar.oracle.apps.fnd.kffdemo.server.KFFAM

Window Title Key Flex Field Demo Window

Title Key Flex Field Demo

8. Create Stack Layout Region Under Page Layout Region


Right click PageLayoutRN > New > Region

Attribute Property

ID MainRN

AM Definition stackLayout

9. Create a New Item of type Flex under the Stack Layout Region
Right click on MainRN > New > Item
Set Following Properties for New Item --

Attribute Property

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID KeyFlexItem

Item Style Flex

Prompt Accounting Key Flex Field

Appl Short Name SQLGL

Name GL#

Type Key

View Instance KFFVO1

10. Create Controller for page KFFPG


Right Click on PageLayoutRN > Set New Controller
Package Name: prajkumar.oracle.apps.fnd.kffdemo.webui
Class Name: KFFCO

Write Following Code in KFFCO processRequest

public void processRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processRequest(pageContext, webBean);

OAKeyFlexBean kffId =
(OAKeyFlexBean)webBean.findIndexedChildRecursive("KeyFlexItem");

// Set the code combination lov


kffId.useCodeCombinationLOV(true);
//set the structure code for the item key flex
kffId.setStructureCode("FED_AFF");
//Set the attribute name to the item
kffId.setCCIDAttributeName("CodeCombinationId");
//Execute the Query
KFFAMImpl am = (KFFAMImpl)pageContext.getApplicationModule(webBean);
KFFVOImpl vo = (KFFVOImpl)am.findViewObject("KFFVO1");

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

if(!vo.isPreparedForExecution())
{
vo.executeQuery();
}
}

Note -- If you do not want to see the key flex field is merging one then change the code in
the controller class as below

kffId.useCodeCombinationLOV(false);

11. Use the below Query to find the Structure Code

SELECT fif.application_id,
fif.id_flex_code,
fif.id_flex_name,
fif.application_table_name,
fif.description,
fifs.id_flex_num,
fifs.id_flex_structure_code,
fifse.segment_name,
fifse.segment_num,
fifse.flex_value_set_id
FROM fnd_id_flexs fif,
fnd_id_flex_structures fifs,
fnd_id_flex_segments fifse
WHERE fif.application_id = fifs.application_id
AND fif.id_flex_code = fifs.id_flex_code
AND fifse.application_id = fif.application_id
AND fifse.id_flex_code = fif.id_flex_code
AND fifse.id_flex_num = fifs.id_flex_num
AND fif.id_flex_code LIKE 'GL#'
AND fif.id_flex_name LIKE 'Accounting Flexfield';

12. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Implement Dependent LOV in OA Framework


Let us try to create a Dependent LOV. In this exercise first Lov Input is “Employee Name”
based on Employee Name Second Lov Input will give “Dependent Name”

1. Create a New Workspace and Project


Right click Workspaces and click create new OAworkspace and name it as
PRajkumarDependentLovDemo.
Automatically a new OA Project will be created. Name the project as DependentLovDemo
and package as prajkumar.oracle.apps.fnd.dependentlovdemo

Note -- Check Run Option Property for Project.

Right Click on DependentLovDemo > Oracle Applications > Run Options. Check OADeveloperMode should not be
inSelected Options if it is there in Selected Options list then shuttle it back to Available Options

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

2. Create a New Application Module (AM)


Right Click on DependentLovDemo > New > ADF Business Components > Application
Module
Name -- DependentLovAM
Package -- prajkumar.oracle.apps.fnd.dependentlovdemo.server

3. Create a New View Object (VO)


Right click on DependentLovDemo > New > ADF Business Components > View Object
Name – DependentLovVO1
Package -- prajkumar.oracle.apps.fnd.dependentlovdemo.server

Note - The VO is not based on any EO so click next and go to the query section and paste the
query

SELECT person_id, full_name


FROM per_all_people_f
WHERE SYSDATE BETWEEN effective_start_date AND effective_end_date

4. Create a New View Object for Second Lov (VO)


Right click on DependentLovDemo > New > ADF Business Components > View Object
Name – DependentLovVO2
Package -- prajkumar.oracle.apps.fnd.dependentlovdemo.server

Note - The VO is not based on any EO so click next and go to the query section and paste the
query

SELECT pcr.person_id, papf.full_name


FROM per_contact_relationships pcr,
per_all_people_f papf
WHERE papf.person_id = pcr.contact_person_id
AND SYSDATE BETWEEN pcr.date_start AND NVL(pcr.date_end,SYSDATE)
AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Add Your View Objects to Root UI Application Module


Select Right click on DependentLovAM > Edit DependentLovAM > Data Model >
Select DependentLovVO1 and DependentLovVO2 and shuttle to Data Model list

Create First LOV Region for VO DependentLovVO1

6. Create First LOV Region


Right click on DependentLovDemo > New > Web Tier > OA Components > Region
Name -- FirstLovRN
Package -- prajkumar.oracle.apps.fnd.dependentlovdemo.webui
Region Style -- listOfValues

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Scope -- Public

Note - The property Scope is the key property which makes the LOV region public and makes
it usable in multiple pages

7. Right click on FirstLovRN and click table using wizard. In the wizard choose the
prajkumar.oracle.apps.fnd.dependentlovdemo.server.DependentLovAM and select
DependentLovVO1_1. Click Next

Region Id – FirstLovRN
Region style – table

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

8. Shuttle the two attributes to the right side.That is PersonId and FullName

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

9. Set Region Item properties as below –

ID Prompt Style Datatype

PersonId_LOV PersonId formValue NUMBER

FullName_LOV FullName messageStyledText VARCHAR2

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

10. Click Next and Finish

11. Select PersonId_LOV and Set Following Properties –

Attribute Property

Search Allowed False

Selective Search Criteria False

12. Select FullName_LOV and Set Following Properties –

Attribute Property

Search Allowed True

Selective Search Criteria False

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Now Same way Create Second LOV Region for VO DependentLovVO2

13. Create Second LOV Region


Right click on DependentLovDemo > New > Web Tier > OA Components > Region
Name -- SecondLovRN
Package -- prajkumar.oracle.apps.fnd.dependentlovdemo.webui
Region Style -- listOfValues
Scope -- Public

Note - The property Scope is the key property which makes the LOV region public and makes
it usable in multiple pages

14. Right click on SecondLovRN and click table using wizard. In the wizard choose the
prajkumar.oracle.apps.fnd.dependentlovdemo.server.DependentLovAM and select
DependentLovVO2_1. Click Next

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Region Id – SecondLovRN
Region style – table

15. Shuttle the two attributes to the right side.That is PersonId and FullName

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

16. Set Region Item properties as below –

ID Prompt Style Datatype

Second_PersonId_LOV PersonId messageStyledText NUMBER

Second_FullName_LOV FullName messageStyledText VARCHAR2

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

17. Click Next and Finish

18. Select Second_PersonId_LOV and Set Following Properties –

Attribute Property

Search Allowed False

Selective Search Criteria True

19. Select Second_FullName_LOV and Set Following Properties –

Attribute Property

Search Allowed True

Selective Search Criteria False

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

20. Create a New Page


Right click on DependentLovDemo > New > Web Tier > OA Components > Page

Attribute Property

Name DependentLovPG

Package prajkumar.oracle.apps.fnd.dependentlovdemo.webui

21. Select the DependentLovPG and go to the strcuture pane where a default region has
been created

22. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

AM prajkumar.oracle.apps.fnd.dependentlovdemo.server.DependentLovAM
Definition

Window Dependent List of values Demo Window


Title

Title Dependent List of values Demo

23. Right click PageLayoutRN and click new Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

24. Create a New item to store Return result of First LOV and to give Search Criteria to
second LOV
Select PageLayoutRN > New > Item
Set following Properties for New Item –

Attribute Property

ID ParentPersonId

Item Style formValue

Data Type Number

Build First LOV on Page:

25. Right click the MainRN and click new messageLovInput


Set Following Properties for Newly Created messageLovInput

Attribute Property

ID Employee_Name

External Lov /prajkumar/oracle/apps/fnd/dependentlovdemo/webui/FirstLovRN

Search Allowed False

Selective Search True


Criteria

Prompt Employee Name

Select LovMap1 and set following properties --

Attribute Property

Lov Region Item FullName_LOV

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Return Item Employee_Name

Criteria Item Employee_Name

Create LovMap2 and set following properties for that --


Select Employee_Name > lovMappings right click New > lovMap
Set following properties for lovMap2 --

Attribute Property

Lov Region Item PersonId_LOV

Return Item ParentPersonId

Build Second LOV on Page:

26. Right click the MainRN and click new messageLovInput


Set Following Properties for Newly Created messageLovInput

Attribute Property

ID Dependent_Name

External Lov /prajkumar/oracle/apps/fnd/dependentlovdemo/webui/SecondLovRN

Search Allowed True

Selective Search True


Criteria

Prompt Dependent Name

Select LovMap3 and set following properties --

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

Lov Region Item Second_FullName_LOV

Return Item Dependent_Name

Programmatic Query True

Create LovMap4 and set following properties for that --


Select Dependent_Name > lovMappings right click New > lovMap
Set following properties for lovMap4 --

Attribute Property

Lov Region Item Second_PersonId_LOV

Criteria Item ParentPersonId

Required True

27. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Implement External LOV in OA Framework


1. Create a New Workspace and Project
Right click Workspaces and click create new OAworkspace and name it as
PRajkumarLovDemo. Automatically a new OA Project is also created. Name the project as
LovDemo and package as prajkumar.oracle.apps.fnd.lovdemo

2. Create a New Application Module (AM)


Right Click on LovDemo > New > ADF Business Components > Application Module
Name -- LovAM
Package -- prajkumar.oracle.apps.fnd.lovdemo.server

3. Create a New View Object (VO)


Right click on LovDemo > New > ADF Business Components > View Object
Name -- LovVO
Package -- prajkumar.oracle.apps.fnd.lovdemo.server

Note - The VO is not based on any EO so click next and go to the query section and paste the
query
SELECT employee_number, full_name
FROM per_all_people_f
WHERE SYSDATE BETWEEN effective_start_date AND effective_end_date

4. Add View Object to Root UI Application Module

5. Create a New Page


Right click on LovDemo > New > Web Tier > OA Components > Page
Name -- LovPG
Package -- prajkumar.oracle.apps.fnd.lovdemo.webui

6. Select the LovPG and go to the strcuture pane where a default region has been created

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

7. Select region1 and set the following properties:


ID -- PageLayoutRN
AM Definition -- prajkumar.oracle.apps.fnd.lovdemo.server.LovAM
Window Title -- List of values Demo Window
Title – List of values Demo

8. Right click PageLayoutRN and click new Region


ID -- MainRN
Region Style – messageComponentLayout
Note - Style is given as messageComponentlayout because we are going to create only
message components that is messageLovInput item in that region

9. Create a New Region


Right click on LovDemo > New > Web Tier > OA Components > Region
Name -- EmployeeLovRN
Package -- prajkumar.oracle.apps.fnd.lovdemo.webui
Region Style -- listOfValues
Scope -- Public

Note - The property Scope is the key property which makes the LOV region public and makes
it usable in multiple pages

10. Select EmployeeLovRN. Right click on EmployeeLovRN in Structure pane and click
table using wizard. In the wizard choose the
prajkumar.oracle.apps.fnd.lovdemo.server.LovAM and select the LovVO1. Click Next
Region Id -- LovRN
Region style -- table

11. Shuttle the two attributes to the right side.That is EmployeeNumber and FullName

12. Click next, check the mapping and then finish

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

13. Select the field FullName and set the following properties:
Search Allowed -- True
Selective Search Criteria – True

Note - The first property lets users search on these values in the LOV, and the second
property ensures that the users specify search criteria for at least one of these values to avoid a
blind query

Attaching External LOV to Page:

14. Click on LovPG and right click the MainRN and click new messageLovInput
External Lov -- /prajkumar/oracle/apps/fnd/lovdemo/webui/EmployeeLovRN
Lov Region Item -- FullName
Return Item -- item1
Criteria Item -- item1
Prompt -- Employee Name

15. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Set Default Value for messageTextInput in OAF


1. Create a New OA Workspace and Empty OA Project
File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarSetDefaultValDemo

Automatically a new OA Project will also be created

Project Name -- SetDefaultProj


Default Package -- prajkumar.oracle.apps.fnd.setdefaultproj

2. Create Application Module AM


Right Click on SetDefaultProj > New > ADF Business Components > Application Module
Name -- SetDefaultAM
Package -- prajkumar.oracle.apps.fnd.setdefaultproj.server
Check Application Module Class: SetDefaultAMImpl Generate JavaFile(s)

3. Create a OA components Page


Right click on SetDefaultProj > New > Web Tier > OA Components > Page
Name -- SetDefaultPG
Package -- prajkumar.oracle.apps.fnd.setdefaultproj.webui

4. Select SetDefaultPG and go to the strcuture pane where a default region has been
created

5. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

Region Style pageLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Form Property True

Auto Footer True

Window Title Set Default Value Window Title

Title Set Default Value Header

AM Definition prajkumar.oracle.apps.fnd.setdefaultproj.SetDefaultAM

6. Create the Second Region


Right click on PageLayoutRN > New > Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

7. Create messageTextInput
MainRN > New > messageTextInput

Attribute Property

ID MyTextitemId

Style Property messageTextInput

Length 20

Maximum Length 50

8. Save Your Work

9. Add a Controller
MainRN > Set New Controller

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Package Name -- prajkumar.oracle.apps.fnd.setdefaultvaldemo.webui


Class Name -- SetDefaultValCO

10. Edit Your Controller


Add Following Code in processRequest

import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
String myValue = "My Default Value";
OAMessageTextInputBean textBean =
(OAMessageTextInputBean)webBean.findChildRecursive("MyTextitemId");
textBean.setValue(pageContext, myValue);
}

11. Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Implement PopList in OA Framework


1. Create a New Workspace and Project
File> New > General> Workspace Configured for Oracle Applications
File Name -- PopListDemo
Project Name – PopListDemo
Default Package -- prajkumar.oracle.apps.fnd.poplistdemo

2. Create a New Application Module (AM)


Right Click on PopListDemo > New > ADF Business Components > Application Module
Name -- poplistdemoAM
Package -- prajkumar.oracle.apps.fnd.poplistdemo.server

3. Create a New View Object (VO)


Right click on PopListDemo > New > ADF Business Components > View Object
Name -- poplistdemoVO
Package -- prajkumar.oracle.apps.fnd.poplistdemo.server
Note - The VO is not based on any EO so click next and go to the query section and paste the
query

SELECT 'poplist_item1' poplist_items


FROM DUAL
UNION
SELECT 'poplist_item2'
FROM DUAL
UNION
SELECT 'poplist_item3'
FROM DUAL

4. Create a New Page


Right click on PopListDemo > New > Web Tier > OA Components > Page
Name -- poplistdemoPG
Package -- prajkumar.oracle.apps.fnd.poplistdemo.webui

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Select the poplistdemoPG and go to the strcuture pane where a default region has been
created

6. Select region1 and set the following properties:


ID -- PageLayoutRN
AM Definition -- prajkumar.oracle.apps.fnd.poplistdemo.server.poplistdemoAM
Window Title -- PopList Demo Window
Title – PopList Demo Header

7. Right click PageLayoutRN and click new Region


ID -- MainRN
Region Style – messageComponentLayout

8. Verify Your VO attribute name


Select poplistdemoVO right click > Edit poplistdemoVO > Attributes >
Verify the Name it should be “poplist_items” if it is not then edit it and enter name
“poplist_items”

9. Create the first Item (Empty Field)


MainRN > New > messageChoice

Set following properties for new item


ID – MyPopList
Required -- Yes
Picklist View Definition -- prajkumar.oracle.apps.fnd.poplistdemo.server.poplistdemoVO
Picklist Display Attribute – poplist_items (Name of Attribute in Your VO)
Picklist Value Attribute -- poplist_items
CSS Class – OraFieldText
Prompt – My PopList

10. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Partial Page Rendering in OAF Page


Let us try to implement partial page rendering for a text item.
If value of TextItem1 is null then TextItem2 will not be appreared on UI.
If value of TextItem1 is not null then TextItem2 will be appreared on UI.

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- PPRProj
Project Name – PPRDemoProj
Default Package -- prajkumar.oracle.apps.fnd.pprdemo

2. Create Application Module AM


PPRDemoProj right click > New > ADF Business Components > Application Module
Name -- PPRAM
Package -- prajkumar.oracle.apps.fnd.pprdemo.server

Check Application Module Class: PPRAMImpl Generate JavaFile(s)

3. Create a PPRVO View Object


PPRDemoProj> New > ADF Business Components > View Objects
Name – PPRVO
Package – prajkumar.oracle.apps.fnd.pprdemo.server

In Attribute Page
Click on New button and create transient primary key attribute with the following properties:

Attribute Property

Name RowKey

Type Number

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Updateable Always

Key Attribute (Checked)

Click New button again and create transient attribute with the following properties:

Attribute Property

Name TextItem2Render

Type Boolean

Updateable Always

Note – No Need to generate any JAVA files for PPRVO

4. Add Your View Object to Root UI Application Module


Right click on PPRAM > Edit PPRAM > Data Model >
Select PPRVO in Available View Objects list and shuttle to Data Model list

5. Create a OA components Page


PPRDemoProj right click > New > OA Components > Page
Name – PPRPG
Package -- prajkumar.oracle.apps.fnd.pprdemo.webui

6. Modify the Page Layout (Top-level) Region

Attribute Property

ID PageLayoutRN

Region Style pageLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Form Property True

Auto Footer True

Window Title PPR Demo Window Title True

Title PPR Demo Page Header

AM Definition prajkumar.oracle.apps.fnd.pprdemo.server.PPRAM

7. Create the Second Region (Main Content Region)


Right click on PageLayoutRN > New > Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

8. Create Two Text Items

Create First messageTextItem --


Right click on MainRN > New > messageTextInput

Attribute Property

ID TextItem1

Region Style messageTextInput

Prompt Text Item1

Length 20

Disable Server Side Validation True

Disable Client Side Validation True

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Action Type firePartialAction

Event TextItem1Change

Submit True

Note -- Disable Client Side Validation and Event property appears after you set the Action
Type property to firePartialAction

Create Second messageTextItem --


Select MainRN right click > New > messageTextInput

Attribute Property

ID TextItem2

Region Style messageTextInput

Prompt Text Item2

Length 20

Rendered ${oa.PPRVO1.TextItem2Render}

9. Add Following code in PPRAMImpl.java

import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
public void handlePPRAction()
{
Number val = 1;
OAViewObject vo = (OAViewObject)findViewObject("PPRVO1");
if (vo != null)
{
if (vo.getFetchedRowCount() == 0)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

{
vo.setMaxFetchSize(0);
vo.executeQuery();
vo.insertRow(vo.createRow());
OARow row = (OARow)vo.first();

row.setAttribute("RowKey", val);
row.setAttribute("TextItem2Render", Boolean.FALSE);
}
}
}

10. Implement Controller for Page


Select PageLayoutRN in Structure pane right click > Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.pprdemo.webui
Class Name – PPRCO

Write following code in processFormRequest function of PPRCO Controller

import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAViewObject;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processRequest(pageContext, webBean);
PPRAMImpl am = (PPRAMImpl)pageContext.getApplicationModule(webBean);

am.invokeMethod("handlePPRAction");
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);

PPRAMImpl am = (PPRAMImpl)pageContext.getApplicationModule(webBean);
OAViewObject vo = (OAViewObject)am.findViewObject("PPRVO1");
OARow row = (OARow)vo.getCurrentRow();

if ("TextItem1Change".equals(pageContext.getParameter(EVENT_PARAM)))
{
if (pageContext.getParameter("TextItem1").equals(""))

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

{
row.setAttribute("TextItem2Render", Boolean.FALSE);
}
else
{
row.setAttribute("TextItem2Render", Boolean.TRUE);
}
}
}

11. Congratulation you have successfully finished. Run Your PPRPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Execute parameterized PL SQL procedure from OAF page


Let us try to call PL/SQL package from OAF page. We will try to send two interger values to
one PL/SQL procedure which will do sum of that numbers and will return back sum of that
numbers

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- ParameterizedProcProj
Project Name – ParameterizedProcDemo
Default Package -- prajkumar.oracle.apps.fnd.parameterizedprocdemo

2. Create Application Module AM


Right click on ParameterizedProcProj > New > ADF Business Components > Application
Module
Name -- ParameterizedProcDemoAM
Package -- prajkumar.oracle.apps.fnd.parameterizedprocdemo.server
Check Application Module Class: ParameterizedProcDemoAMImpl Generate JavaFile(s)

3. Create a New Page


Right click on ParameterizedProcProj > New > Web Tier > OA Components > Page
Name -- ParameterizedProcDemoPG
Package -- prajkumar.oracle.apps.fnd.parameterizedprocdemo.webui

4. Select region1 and set the following properties:


ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition --
prajkumar.oracle.apps.fnd.parameterizedprocdemo.server.ParameterizedProcDemoAM
Window Title – Execute Paramterized Procedure Demo Page Window
Title – Execute Paramterized Procedure Demo Page Header
Auto Footer – True

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Add a New Region MainRN


Select PageLayoutRN right click > New > Region
ID -- MainRN
Region Style – messageComponentLayout

6. Create messageTextInput Items

Create item1
Select MainRN > New > messageTextInput
Set following Properties for Text Item1
ID – item1
Item Style – messageTextInput
Data Type -- Number
Prompt – Text Item1
Maximum Length – 20
Length -- 20

Create item2
Select MainRN > New > messageTextInput
Set following Properties for Text Item1
ID – item2
Item Style – messageTextInput
Data Type -- Number
Prompt – Text Item2
Maximum Length – 20
Length -- 20

7. Create a Submit Button


Right Click on MainRN > New > messageLayout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Select newly created messageLayout right click > New > item
Set Following Properties for newly created item
ID – Sum
Item Style – submitButton
Attribute Set -- /oracle/apps/fnd/attributesets/Buttons/Go
Prompt – Sum

8. Run Your Page UI is ready --

9. Let us create a package and package body which we will call from OAF page
This Package takes three parameters all are number. First two are IN parameters and last is
OUT as sum of first two numbers

Package Spec

CREATE OR REPLACE PACKAGE APPS.test_package AUTHID CURRENT_USER


IS
PROCEDURE data_sum
( item1 IN NUMBER,
item2 IN NUMBER,
data_sum OUT NUMBER
);
END test_package;
/
SHOW ERRORS;

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

EXIT;

Package Body

CREATE OR REPLACE PACKAGE BODY APPS.test_package


IS
PROCEDURE data_sum
( item1 IN NUMBER,
item2 IN NUMBER,
data_sum OUT NUMBER
)
IS
BEGIN
data_sum := item1 + item2;
END data_sum;
END test_package;
/
SHOW ERRORS;
EXIT;

10. Add Following Code in your AMImpl Class (ParameterizedProcDemoAMImpl.java)

import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OADBTransactionImpl;
import oracle.jdbc.OracleCallableStatement;
import java.sql.Types;
import oracle.apps.fnd.framework.OAException;
...
public String dataSumAction(String item1,String item2)
{ OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
String retValues;
StringBuffer str = new StringBuffer();
str.append( " BEGIN ");
str.append( " test_package.data_sum( ");
str.append( " item1 => :1, ");
str.append( " item2 => :2, ");
str.append( " data_sum => :3 ");
str.append( " ); ");
str.append( " END; ");

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OracleCallableStatement oraclecallablestatement =
(OracleCallableStatement)oadbtransaction.createCallableStatement(str.toString(), 1);
try{
oraclecallablestatement.setInt(1, Integer.parseInt(item1) );
oraclecallablestatement.setInt(2, Integer.parseInt(item2) );
oraclecallablestatement.registerOutParameter(3, Types.VARCHAR);
oraclecallablestatement.execute();

retValues = oraclecallablestatement.getString(3);
}
catch(Exception e)
{
throw OAException.wrapperException(e);
}
return retValues;
}

11. Add Controller for Page ParameterizedProcDemoPG Select PageLayoutRN right click
Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.parameterizedprocdemo.webui
Class Name -- ParameterizedProcDemoCO
Add Following Code in Controller

import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
...
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);

OAApplicationModule am = pageContext.getApplicationModule(webBean);

if (pageContext.getParameter("Sum") != null)
{
Serializable[] parameters1 = { pageContext.getParameter("item1"),
pageContext.getParameter("item2"),
};

String retVals1 = (String)am.invokeMethod("dataSumAction", parameters1);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

String message = "Sum: " + retVals1;


throw new OAException(message, OAException.INFORMATION);
}
}

12. Congratulation you have successfully finished. Run Your ParameterizedProcDemoPG


page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Implement Train in OAF Page


Let us try to implement train between three pages. Consider three pages each having Text
Item

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- TrainProj
Project Name – TrainDemoProj
Default Package -- prajkumar.oracle.apps.fnd.traindemo

2. Create Application Module AM


TrainDemoProj right click > New > ADF Business Components > Application Module
Name -- TrainDemoAM
Package -- prajkumar.oracle.apps.fnd.traindemo.server
Check Generate JavaFile(s)

Create Three Pages TrainDemoPG1, TrainDemoPG2 and TrainDemoPG3 as similar way as


mention below to create TrainDemoPG1
3. Create a OA components Pages
TrainDemoProj right click > New > OA Components > Page
Name – TrainDemoPG1
Package -- prajkumar.oracle.apps.fnd.traindemo.webui

4. Modify the Page Layout (Top-level) Region

Attribute Property

ID PageLayoutRN

Region Style pageLayout

Form Property True

Auto Footer True

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Window Title Train Demo Window Title

Title Train Demo Page Header

AM Definition prajkumar.oracle.apps.fnd.traindemo.server.TrainDemoAM

5. Create the Second Region (Main Content Region)


Select PageLayoutRN right click > New > Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

Create Text Items for all three pages say TextItemPage1, TextItemPage2 and TextItemPage3
in respective pages TrainDemoPG1, TrainDemoPG2 and TrainDemoPG3 in similar way of
as mention below to create TextItemPage1 in page TrainDemoPG1
6. Create Text Items
Select MainRN right click > New > messageTextInput
Prompt – TextItemPage1
Length -- 20

7. Create a Standalone Train Region


TrainDemoProj > New > Web Tier > OA Components > Region
Name -- TrainRN
Package – prajkumar.oracle.apps.fnd.traindemo.webui
Style – train
Select TrainRN inStructure pane and open property inspector and set Allow
Interactionproperty to True

8. Add Three Train Nodes to TrainRN


Right Click on TrainRN in Structure pane > New > Link

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Set the link properties as follow --


ID – TrainStep1
Item Style – link
Text – Step 1
Destination URI –
OA.jsp?page=/prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG1

Right Click on TrainRN in Structure pane > New > Link


Set the link properties as follow --
ID – TrainStep2
Item Style – link
Text – Step 2
Destination URI –
OA.jsp?page=/prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG2

Right Click on TrainRN in Structure pane > New > Link


Set the link properties as follow --
ID – TrainStep3
Item Style – link
Text – Step 3
Destination URI –
OA.jsp?page=/prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG3

9. Add Train Region to each of your Pages


For each of three pages in multistep flow, right click the pageLayoutRN in structure panel,
and select New > location from page Context menu
Set following properties as follow --
ID – TrainDemoRN
Extends -- /prajkumar/oracle/apps/fnd/traindemo/webui/TrainRN

10. Create a Standalone (Shared) TrainFooterRN


TrainDemoProj > New > Web Tier > OA Components > Region

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Name -- TrainFooterRN
Package -- prajkumar.oracle.apps.fnd.traindemo.webui
Region Style -- pageButtonBar

11. Add navigrationBar


Select TrainFooterRN in Structure pane right click > New > Region
Set the region properties as follows:
ID -- NavBar
Region Style – navigationBar
First Step – 1
Last Step – 3

12. Add Links to the navigrationBar


Right Click on NavBar > New > link
Set Item‟s properties as follows:
ID – Step1Link
Item Style – link
Text – Step 1 of 3: Page1
Warn About Changes – False
Destination URI -- /prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG1

Right Click on NavBar > New > link


Set Item‟s properties as follows:
ID – Step2Link
Item Style – link
Text – Step 2 of 3: Page2
Warn About Changes – False
Destination URI -- /prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG2

Right Click on NavBar > New > link

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Set Item‟s properties as follows:


ID – Step3Link
Item Style – link
Text – Step 3 of 3: Page3
Warn About Changes – False
Destination URI -- /prajkumar/oracle/apps/fnd/traindemo/webui/TrainDemoPG3

13. Initialize the Footer Region


Select TrainFooterRN in Structure pane right click > Set New Controller
Class Name -- TrainDemoCO
Package Name – prajkumar.oracle.apps.fnd.traindemo.webui
Add following code in processRequest()

import oracle.apps.fnd.framework.webui.beans.nav.OATrainBean;
import oracle.apps.fnd.framework.webui.beans.nav.OANavigationBarBean;
...
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OATrainBean trainBean =
(OATrainBean)pageContext.getPageLayoutBean().getLocation();
trainBean.prepareForRendering(pageContext);

int step = trainBean.getSelectedTrainStepRenderedIndex();


OANavigationBarBean navBean =
(OANavigationBarBean)webBean.findChildRecursive("NavBar");
navBean.setValue(step+1);
} // end processRequest()

14. Add the Navigation Region to your pages


For each of three pages in the multistep flow, right click the PageLayoutRN in Structure pane
and select New > Region
Set the region‟s properties as follow:
ID -- PageButtonBar

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Style -- pageButtonBar
Extends -- /prajkumar/oracle/apps/fnd/traindemo/webui/TrainFooterRN
15. Congratulation you have successfully finished. Run Your TrainDemoPG1 page and Test
Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Oracle D2K to OA Framework Transformation


What is the difference between Oracle D2K form and OA Framework?
It is a very innocent but important question for someone that desires to make
transition from D2K to OA Framework. I hope you have already read and
implemented OA Framework Getting Started.

I will re-visit my own experience of implementing HelloWorld program in "OA


Framework". When I implemented HelloWorld a year ago, I had no clue as to what I
was doing & why I was doing those steps. I merely copied the steps from Oracle
Tutorial without understanding them.
Hence in this blog, I will try to explain in simple manner the meaning of
OA Framework HelloWorld Program and compare the steps to D2K form [where
possible]. To keep things simple, only basics will be discussed.
Following key Steps were needed for HelloWorld

Step 1

Create a new Workspace and a new Project as dictated by Oracle's tutorial. When
defining project, you will specify a default package, which in this case was
oracle.apps.ak.hello
This means the following: -

 ak is the short name of the Application in Oracle

[means fnd_applications.short_name]

 hello is the name of your project

Step 2
Next, you will create a OA Page within hello project
Think OA Page as the fmx file itself in D2K. I am saying so because this page gets
attached to the form function.

 This page will be created within hello project, hence the package
nameoracle.apps.ak.hello.webui
 Note the webui, it is a convention to have page in webui, means this page
represents the Web User Interface
 You will assign the default AM [OAApplicationModule]. Think of AM
"Connection Manager" and "Transaction State Manager" for your page

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

I can't co-relate this to anything in D2k, as there is no concept of Connection


Pooling and that D2k is not stateless. Reason being that as soon as you kick off a D2K
Form, it connects to a single session of Oracle and sticks to that single Oracle database
session. So is not the case in OAF, hence AM is needed.
Step 3

You create Region within the Page.


 Region is what will store your fields. Text input fields will be of type
messageTextInput. Think of Canvas in D2K. You can have nested regions. Stacked
Canvas in D2K comes the closest to this component of OA Framework
Step 4
Add a button to one of the nested regions

 The itemStyle should be submitButton, in case you want the page to be


submitted when this button is clicked
 There is no WHEN-BUTTON-PRESSED trigger in OAF. In Framework, you
will add a controller java code to handle events like Form Submit button clicks.
JDeveloper generates the default code for you. Primarily two functions [should I
call methods] will be created processRequest [for UI Rendering Handling] and
processFormRequest

Think of processRequest as WHEN-NEW-FORM-INSTANCE, though


processRequest is very restrictive.
Note
What is the difference between processRequest and processFormRequest?
These two methods are available in the Default Controller class that gets created.
processFormRequest
This method is commonly used to react/respond to the event that has taken place, for
example click of a button.

Some examples are


if(oapagecontext.getParameter("Cancel") != null) (Do your processing
for Cancellation/ Rollback)
if(oapagecontext.getParameter("Submit") != null) (Do your validations and commit
here)
if(oapagecontext.getParameter("Update") != null) (Do your validations and commit
here)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

In the above three examples, you could be calling oapagecontext.forwardImmediately


to re-direct the page navigation to some other page if needed.
processRequest
In this method, usually page rendering related code is written. Effectively, each GUI
component is a bean that gets initialised during processRequest. Those who are
familiar with D2K forms, something like pre-query may be written in this method.
Step 5
In the controller to access the value in field "HelloName" the command is
String userContent = pageContext.getParameter("HelloName");
In D2k, we used :block.field.
In OAFramework, at submission of page, all the field values get passed into to
OAPageContext object.

 Use getParameter to access the field value


 To set the value of the field, use

OAMessageTextInputBean field
HelloName =
(OAMessageTextInputBean)webBean.findChildRecursive("HelloName");
fieldHelloName.setText(pageContext,"Setting the default value" );

Note when setting field value in controller:


Note 1. Do not set the value in processFormRequest
Note 2. If the field comes from View Object, then do not use setText in controller
Note 3. For control fields [that are not based on View Objects], you can use setText to
assign values in processRequest method

Lets take some notes to expand beyond the HelloWorld Project


Note 1
In D2K-forms we sort of created a Window, attached to Canvas, and then fields within
that Canvas.
However in OA Framework, think of Page being fmx/Window, think of Region being
a Canvas, and fields being within Regions.
This is not a formal/accurate understanding of analogy between D2k and Framework,
but is close to being logical.
Note 2

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

In D2k, your Forms fmb file was compiled to fmx. It was fmx file that was deployed
on mid-tier. In case of OAF, your OA Page is nothing but a XML file. We call this MDS
[meta data].
Whatever name you give to "Page" in OAF, an XML file of the same name gets
created. This xml file must then be loaded into database by using XML Importer
command.
Note 3
Apart from MDS XML file, almost everything else is merely deployed to your mid-
tier. Usually this is underneath $JAVA_TOP/oracle/apps/../..
All java files will go underneath java top/oracle/apps/../.. etc.

Note 4
When building tutorial, ignore the steps for setting "Attribute Sets". These are not
mandatory. Oracle might just have developed their tutorials without including these.
Think of these like Visual Attributes of D2K forms

Note 5
Controller is where you will write any java code in OA Framework. You can create a
Controller per Page or have a different Controller for each of the Regions with the
same Page.

Note 6
In the method processFormRequest of the Controller, you can access the values of the
page by using notation pageContext.getParameter("<fieldname here>").
This method processFormRequest is executed when the OAF Screen/Page is
submitted by click of a button.

Note 7
Inside the controller, all the Database Related interactions for example interaction
with View Objects happen via Application Module.
But why so? Because Application Module Manages the transaction state of the
Application.
OAApplicationModuleImpl oaapplicationmoduleimpl =
OAApplicationModuleImpl)oapagecontext.getApplicationModule(oawebbean);
OADBTransaction oadbtransaction =
OADBTransaction)oaapplicationmoduleimpl.getDBTransaction();

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Note 8
In D2K, we have control block or a block based on database view. Similarly, in OA
Framework, if the field does not have view Object attached, then it is like a control
field. Hence in HelloWorld example, field HelloName is a control field [in D2K
terminology]. A view Object can either be based on a view/table, synonym or on a
SQL statement.

Note 9
I wish to access the fields in multi record block that is based on view Object. Can I do
this in Controller?
Sure you can. To traverse through those records, do the below
 Get the reference to the View Object using
(OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject("
VO Name Here")
 Loop through the records in View Objects using count returned from
oaviewobject.getFetchedRowCount()
 For each record, fetch the value of the fields within the loop as
oracle.jbo.Row row = oaviewobject.getRowAtRangeIndex(loop index here);
(String)row.getAttribute("Column name of VO here ");

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Call D2K Form from OAF Page


This blog is about to call D2K form from OAF page. We will try to implement a OAF page
to Call Application Developer > Profile Form by clicking Go Button

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- CallformfromOAF
Project Name – Calld2kformfromOAF
Default Package -- prajkumar.oracle.apps.fnd.Calld2kformfromOAF

2. Set Run Options in OA Project Setting


Select Your Project in the Navigator and choose Project Properties
Select Oracle Applications > Run Options
Select OADeveloperMode and OADiagnostic, and move them to selected Options List

3. Create Application Module AM


Calld2kformfromOAF right click > New > ADF Business Components > Application Module
Name -- Calld2kformfromOAFAM
Package -- prajkumar.oracle.apps.fnd.Calld2kformfromOAF.server
Check Generate JavaFile(s)

4. Create a OA components Page


Calld2kformfromOAF right click > New > OA Components > Page
Name -- Calld2kformfromOAFPG
Package -- prajkumar.oracle.apps.fnd.Calld2kformfromOAF.webui

5. Modify the Page Layout (Top-level) Region

Attribute Property

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID PageLayoutRN

Region Style pageLayout

Form Property True

Auto Footer True

Window Title Call D2K from OAF Page Window Title

Title Call D2K from OAF Page Header

AM Definition prajkumar.oracle.apps.fnd.Calld2kformfromOAF.server.
Calld2kformfromOAFAM

6. Create the Second Region (Main Content Region)


Select PageLayoutRN right click > New > Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

7. Create a container Region for Go-Button


Select MainRN right click > New > messageLayout

Attribute Property

Region ButtonLayout

8. Create a Second Item (Go Button)


Select ButtonLayout > New > Item

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID Go

Item Style submitButton

Attribute Set /oracle/apps/fnd/attributesets/Buttons/Go

9. Add a Controller
Select MainRN right click > Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.Calld2kformfromOAF.webui
Class Name -- Calld2kformfromOAFCO

10. Edit Your Controller


Add Following Code in processFormRequest
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Go") != null)
{
//form:APPLICATION_SHORT_NAME:RESPONSIBILITY_KEY:DATA_GROUP_NAME
//:FORM_FUNCTION_NAME

String destination =
"form:FND:APPLICATION_DEVELOPER:STANDARD:FND_FNDPOMPO";

pageContext.forwardImmediatelyToForm(destination);
}
}

11. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Call OAF Page from D2K form


This blog is about to call OAF page from D2K form. We will take one D2K form from there
we will try to call our OAF Page with parameters. In OAF page, there it will show that
parameter values as message when it will open

Let us Create Our OAF Page

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name – CallOAFfromD2KForm
Project Name – CallOAFfromD2KProj
Default Package -- prajkumar.oracle.apps.fnd.CallOAFfromD2K

2. Create Application Module AM


CallOAFfromD2KProj right click > New > ADF Business Components > Application Module
Name -- CallOAFfromD2KAM
Package -- prajkumar.oracle.apps.fnd.CallOAFfromD2K.server
Check Generate JavaFile(s)

3. Create a OA components Page


CallOAFfromD2KProj right click > New > OA Components > Page
Name -- CallOAFfromD2KPG
Package -- prajkumar.oracle.apps.fnd.CallOAFfromD2K.webui

4. Modify the Page Layout (Top-level) Region


ID -- PageLayoutRN
Region Style – pageLayout
Form Property – True
Auto Footer -- True
Window Title – OAF Page Call From D2K Form Window Title

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Title -- OAF Page Call From D2K Form Header


AM Definition -- prajkumar.oracle.apps.fnd.CallOAFfromD2K.server.CallOAFfromD2KAM

5. Consider following D2K form


This Form has First Name and Last Name. We will send First Name and Last Name values to
our OAF page as parameter

6. Add following Code in WHEN_BUTTON_PRESSED trigger of SUBMIT button

DECLARE
BEGIN
fnd_function.execute

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

( FUNCTION_NAME =>'CALL_OAF_FROM_D2K',
OPEN_FLAG =>'Y',
SESSION_FLAG =>'Y',
OTHER_PARAMS =>'FIRSTNAME=' ||
:CALLOAFFROMD2KBLOCK.FIRST_NAME || '&LASTNAME=' ||
:CALLOAFFROMD2KBLOCK.LAST_NAME
);
END;

Note – Here FUNCTION_NAME is OAF page function name

7. Add a Controller in OAF Page


Select PageLayoutRN right click > Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.CallOAFfromD2K.webui
Class Name -- CallOAFfromD2KCO

8. Add following Code in Controller

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

import oracle.apps.fnd.framework.OAException;
...
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{ super.processFormRequest(pageContext, webBean);

String firstName = pageContext.getParameter("FIRSTNAME") ;


String lastName = pageContext.getParameter("LASTNAME") ;

String message = "Hello " + firstName + " " + lastName;

throw new OAException(message, OAException.INFORMATION);


}

9. Build Your Controller

10. Congratulation you have successfully finished. Run Form and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Get Host Name and URL of OAF Page


This blog is about to get Host name and URL of OAF page. We will try to implement one
button which will give host and URL of OAF page

1. Create a New OA Workspace and Empty OA Project


File> New > General> Workspace Configured for Oracle Applications
File Name -- HostandURL
Project Name – HostandURLProj
Default Package -- prajkumar.oracle.apps.fnd.hostandurl

2. Set Run Options in OA Project Setting


Select Your Project in the Navigator and choose Project Properties
Select Oracle Applications > Run Options
Select OADeveloperMode and OADiagnostic, and move them to selected Options List

3. Create Application Module AM


HostandURLProj right click > New > ADF Business Components > Application Module
Name -- HostandURLAM
Package -- prajkumar.oracle.apps.fnd.hostandurl.server
Check Generate JavaFile(s)

4. Create a OA components Page


HostandURLProj right click > New > OA Components > Page
Name -- HostandURLPG
Package -- prajkumar.oracle.apps.fnd.hostandurl.webui

5. Modify the Page Layout (Top-level) Region

Attribute Property

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID PageLayoutRN

Region Style pageLayout

Form Property True

Auto Footer True

Window Title Get Host and URL Window Title

Title Get Host and URL Page Header

AM Definition prajkumar.oracle.apps.fnd.hostandurl.server.HostandURLAM

6. Create the Second Region (Main Content Region)


Select PageLayoutRN right click > New > Region

Attribute Property

ID MainRN

Region Style messageComponentLayout

7. Create a container Region for Go-Button


Select MainRN right click > New > messageLayout

Attribute Property

Region ButtonLayout

8. Create a Item (Go Button)


Select ButtonLayout > New > Item

Attribute Property

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

ID Go

Item Style submitButton

Attribute Set /oracle/apps/fnd/attributesets/Buttons/Go

9. Add a Controller
Select MainRN right click > Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.hostandurl.webui
Class Name -- HostandURLCO

10. Edit Your Controller

Add Following Code in processFormRequest

import java.net.*;
import java.io.*;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAPageContext;
public void processFormRequest(OAPageContext pageContext, OAWebBean
webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Go") != null)
{
// To get Host Name
try
{
InetAddress addr = InetAddress.getLocalHost();
byte[ ] ipAddr = addr.getAddress();
String hostname = "Host Name: " +addr.getHostName();
pageContext.putDialogMessage(new OAException(hostname,
OAException.WARNING));
}
catch (UnknownHostException e)
{
}
// To Get Page URL

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

String pageURL = "Current Page URL: " + pageContext.getCurrentUrl ();

pageContext.putDialogMessage(new OAException(pageURL,
OAException.WARNING));
}
}

11. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OAF Page to Upload Files into Server from local Machine


1. Create a New Workspace and Project
File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarFileUploadDemo

Automatically a new OA Project will also be created

Project Name -- FileUploadDemo


Default Package -- prajkumar.oracle.apps.fnd.fileuploaddemo

2. Create a New Application Module (AM)


Right Click on FileUploadDemo > New > ADF Business Components > Application Module
Name -- FileUploadAM
Package -- prajkumar.oracle.apps.fnd.fileuploaddemo.server
Check Application Module Class: FileUploadAMImpl Generate JavaFile(s)

3. Create a New Page


Right click on FileUploadDemo > New > Web Tier > OA Components > Page
Name -- FileUploadPG
Package -- prajkumar.oracle.apps.fnd.fileuploaddemo.webui

4. Select the FileUploadPG and go to the strcuture pane where a default region has been
created

5. Select region1 and set the following properties --

Attribute Property

ID PageLayoutRN

AM Definition prajkumar.oracle.apps.fnd.fileuploaddemo.server.FileUploadAM

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Window Title Uploading File into Server from Local Machine Demo Window

Title Uploading File into Server from Local Machine Demo

6. Create messageComponentLayout Region Under Page Layout Region


Right click PageLayoutRN > New > Region

Attribute Property

ID MainRN

Item Style messageComponentLayout

7. Create a New Item messageFileUpload Bean under MainRN


Right click on MainRN > New > messageFileUpload
Set Following Properties for New Item --

Attribute Property

ID MessageFileUpload

Item Style messageFileUpload

8. Create a New Item Submit Button Bean under MainRN


Right click on MainRN > New > messageLayout
Set Following Properties for messageLayout --

Attribute Property

ID ButtonLayout

Right Click on ButtonLayout > New > Item

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID Submit

Item Style submitButton

Attribute Set /oracle/apps/fnd/attributesets/Buttons/Go

9. Create Controller for page FileUploadPG


Right Click on PageLayoutRN > Set New Controller
Package Name: prajkumar.oracle.apps.fnd.fileuploaddemo.webui
Class Name: FileUploadCO

Write Following Code in FileUploadCO processFormRequest


import oracle.cabo.ui.data.DataObject;
import java.io.FileOutputStream;
import java.io.InputStream;
import oracle.jbo.domain.BlobDomain;
import java.io.File;
import oracle.apps.fnd.framework.OAException;
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{ super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
{
upLoadFile(pageContext,webBean);
}
}

CODE #1 -- If Page has not deployed at instance, testing at Local Machine, use following
Code
public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
{ String filePath = "D:\\PRajkumar";
System.out.println("Default File Path---->"+filePath);
String fileUrl = null;
try
{

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

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("D:\\PRajkumar", 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);
}
}

CODE #2 -- If Page has been Deployed at Instance, Use Following Code


public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
{ String filePath = "/u01/app/apnac03r12/PRajkumar/";
System.out.println("Default File Path---->"+filePath);
String fileUrl = null;
try

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

{
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("/u01/app/apnac03r12/PRajkumar", 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);
}
}

10. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Page has deployed and Used CODE #2

Before Upload the File

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

After Upload the File

Page has not been deployed and Used CODE #1

Before Upload the File

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

After Upload the File

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

How to deploy JAR file into R12 server in OA


Steps to add JAR file into R12 server in OA --

1. Deploy your JAR file at some custom location in R12 server


i.e. –
/u01/app/apnac03r12/XX_TEST/

2. Open “orion-application.xml” file present at path –


$ORA_CONFIG_HOME/10.1.3/j2ee/oacore/application-deployments/oacore/

3. Edit “orion-application.xml” file to add JAR file path


i.e. –
<library path="/u01/app/apnac03r12/XX_TEST/jxl.jar" />

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

4. Bounce Apache Server

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Import Data from Excel sheet to DB Table through OAF page


1. Create a New Workspace and Project
File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarImportxlsDemo

Automatically a new OA Project will also be created

Project Name -- ImportxlsDemo


Default Package -- prajkumar.oracle.apps.fnd.importxlsdemo

2. Add JAR file jxl-2.6.3.jar to Apache Library


Download jxl-2.6.3.jar from following link –
http://www.findjar.com/jar/net.sourceforge.jexcelapi/jars/jxl-2.6.jar.html

Steps to add jxl.jar file in Local Machine


Right Click on ImportxlsDemo > Project Properties > Libraries > Add jar/Directory and
browse to directory where jxl-2.6.3.jar has been downloaded and select the JAR file

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click here to know Steps to Add JAR file into R12 server in OA

3. Create a New Application Module (AM)


Right Click on ImportxlsDemo > New > ADF Business Components > Application Module
Name -- ImportxlsAM
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server

Check Application Module Class: ImportxlsAMImpl Generate JavaFile(s)

4. Create Test Table in which we will insert data from excel


CREATE TABLE xx_import_excel_data_demo
( -- --------------------

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

-- Data Columns
-- --------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
column3 VARCHAR2(100),
column4 VARCHAR2(100),
column5 VARCHAR2(100),
-- --------------------
-- Who Columns
-- --------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

5. Create a New Entity Object (EO)


Right click on ImportxlsDemo > New > ADF Business Components > Entity Object
Name – ImportxlsEO
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.schema.server
Database Objects -- XX_IMPORT_EXCEL_DATA_DEMO

Note – By default ROWID will be the primary key if we will not make any column to be
primary key
Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on ImportxlsDemo > New > ADF Business Components > View Object
Name -- ImportxlsVO
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server

In Step2 in Entity Page select ImportxlsEO and shuttle it to selected list


In Step3 in Attributes Window select all columns and shuttle them to selected list

In Java page Uncheck Generate Java file for View Object Class: ImportxlsVOImpl

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Select Generate Java File for View Row Class: ImportxlsVORowImpl -> Generate Java File ->
Accessors

7. Add Your View Object to Root UI Application Module


Right click on ImportxlsAM > Edit ImportxlsAM > Data Model >
Select ImportxlsVO and shuttle to Data Model list

8. Create a New Page


Right click on ImportxlsDemo > New > Web Tier > OA Components > Page
Name -- ImportxlsPG
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.webui

9. Select the ImportxlsPG and go to the strcuture pane where a default region has been
created

10. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

AM Definition prajkumar.oracle.apps.fnd.importxlsdemo.server.ImportxlsAM

Window Title Import Data From Excel through OAF Page Demo Window

Title Import Data From Excel through OAF Page Demo

11. Create messageComponentLayout Region Under Page Layout Region


Right click PageLayoutRN > New > Region

Attribute Property

ID MainRN

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Item Style messageComponentLayout

12. Create a New Item messageFileUpload Bean under MainRN


Right click on MainRN > New > messageFileUpload
Set Following Properties for New Item --

Attribute Property

ID MessageFileUpload

Item Style messageFileUpload

13. Create a New Item Submit Button Bean under MainRN


Right click on MainRN > New > messageLayout
Set Following Properties for messageLayout --

Attribute Property

ID ButtonLayout

Right Click on ButtonLayout > New > Item

Attribute Property

ID Go

Item Style submitButton

Attribute Set /oracle/apps/fnd/attributesets/Buttons/Go

14. Create Controller for page ImportxlsPG


Right Click on PageLayoutRN > Set New Controller

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Package Name: prajkumar.oracle.apps.fnd.importxlsdemo.webui


Class Name: ImportxlsCO

Write Following Code in ImportxlsCO in processFormRequest


import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import java.io.Serializable;
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;
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Go") != null)
{
DataObject fileUploadData =
(DataObject)pageContext.getNamedDataObject("MessageFileUpload");
String fileName = null;

try
{
fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
}
catch(NullPointerException ex)
{
throw new OAException("Please Select a File to Upload", OAException.ERROR);
}
BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null,
fileName);
try
{
OAApplicationModule oaapplicationmodule = pageContext.getRootApplicationModule();
Serializable aserializable2[] = {uploadedByteStream};
Class aclass2[] = {BlobDomain.class };
oaapplicationmodule.invokeMethod("ReadExcel", aserializable2,aclass2);
}
catch (Exception ex)
{
throw new OAException(ex.toString(), OAException.ERROR);
}
}

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Write Following Code in ImportxlsAMImpl.java


import java.io.IOException;
import java.io.InputStream;
import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.Row;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.domain.BlobDomain;
public void createRecord(String[] excel_data)
{
OAViewObject vo = (OAViewObject)getImportxlsVO1();

if (!vo.isPreparedForExecution())
{
vo.executeQuery();
}

Row row = vo.createRow();


try
{
for (int i=0; i < excel_data.length; i++)
{
row.setAttribute("Column" +(i+1) ,excel_data[i]);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
vo.insertRow(row);
getTransaction().commit();
}

public void ReadExcel(BlobDomain fileData) throws IOException


{

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

String[] excel_data = new String[5];


InputStream inputWorkbook = fileData.getInputStream();
Workbook w;

try
{
w = Workbook.getWorkbook(inputWorkbook);

// Get the first sheet


Sheet sheet = w.getSheet(0);

for (int i = 0; i < sheet.getRows(); i++)


{
for (int j = 0; j < sheet.getColumns(); j++)
{
Cell cell = sheet.getCell(j, i);
CellType type = cell.getType();
if (cell.getType() == CellType.LABEL)
{
System.out.println("I got a label " + cell.getContents());
excel_data[j] = cell.getContents();
}
else if (cell.getType() == CellType.NUMBER)
{
System.out.println("I got a number " + cell.getContents());
excel_data[j] = cell.getContents();
}
else
{
excel_data[j] = "";
}
}
createRecord(excel_data);
}
}

catch (BiffException e)
{
e.printStackTrace();
}
}

15. Congratulation you have successfully finished. Run Your page and Test Your Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Consider Excel PRAJ_TEST.xls with following data --

Lets Try to import this data into DB Table --

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Import Data from *.xlsx file to DB Table through OAF page


1. Create a New Workspace and Project
File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarImportxlsDemo

Automatically a new OA Project will also be created

Project Name -- ImportxlsDemo


Default Package -- prajkumar.oracle.apps.fnd.importxlsdemo

2. Add following JAR files to Apache Library


1. poi-ooxml-3.7.jar
http://grepcode.com/snapshot/repo1.maven.org/maven2/org.apache.poi/poi-ooxml/3.7

2. ooxml-schemas-1.1.jar
http://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas/1.1

3. stax-api-1.0.1.jar
http://www.jarfinder.com/index.php/jars/versionInfo/69009

4. log4j-1.2.16.jar
http://mvnrepository.com/artifact/log4j/log4j/1.2.16

5. poi-ooxml-schemas-3.7.jar
http://mavenhub.com/mvn/central/org.apache.poi/poi-ooxml-schemas/3.7

6. poi-3.7-20101029.jar
http://mvnrepository.com/artifact/org.apache.poi/poi/3.7-beta1

7. xmlbeans-2.4.0.jar

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

http://www.jarfinder.com/index.php/jars/versionInfo/14387

8. dom4j-1.6.1.jar
http://grepcode.com/snapshot/repo1.maven.org/maven2/dom4j/dom4j/1.6.1

Steps to add JAR files in Local Machine


Right Click on ImportxlsDemo > Project Properties > Libraries > Add jar/Directory and
browse to directory where all JAR files have been downloaded and select the JAR files

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click here to know Steps to Add JAR file into R12 server in OA

3. Create a New Application Module (AM)


Right Click on ImportxlsDemo > New > ADF Business Components > Application Module
Name -- ImportxlsAM
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server
Check Application Module Class: ImportxlsAMImpl Generate JavaFile(s)

4. Create Test Table in which we will insert data from *.xlsx file
CREATE TABLE xx_import_excel_data_demo
( -- --------------------
-- Data Columns

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

-- --------------------
column1 VARCHAR2(100),
column2 VARCHAR2(100),
column3 VARCHAR2(100),
column4 VARCHAR2(100),
column5 VARCHAR2(100),
-- --------------------
-- Who Columns
-- --------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

5. Create a New Entity Object (EO)


Right click on ImportxlsDemo > New > ADF Business Components > Entity Object
Name – ImportxlsEO
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.schema.server
Database Objects -- XX_IMPORT_EXCEL_DATA_DEMO

Note – By default ROWID will be the primary key if we will not make any column to be
primary key

Check the Accessors, Create Method, Validation Method and Remove Method

6. Create a New View Object (VO)


Right click on ImportxlsDemo > New > ADF Business Components > View Object
Name -- ImportxlsVO
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.server

In Step2 in Entity Page select ImportxlsEO and shuttle it to selected list


In Step3 in Attributes Window select all columns and shuttle them to selected list

In Java page

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Select Generate Java File for View Object Class: ImportxlsVOImpl -> Generate Java File ->
Bind Variable Accessors
Select Generate Java File for View Row Class: ImportxlsVORowImpl -> Generate Java File ->
Accessors

7. Add Your View Object to Root UI Application Module


Right click on ImportxlsAM > Edit ImportxlsAM > Data Model >
Select ImportxlsVO and shuttle to Data Model list

8. Create a New Page


Right click on ImportxlsDemo > New > Web Tier > OA Components > Page
Name -- ImportxlsPG
Package -- prajkumar.oracle.apps.fnd.importxlsdemo.webui

9. Select the ImportxlsPG and go to the strcuture pane where a default region has been
created

10. Select region1 and set the following properties:

Attribute Property

ID PageLayoutRN

AM Definition prajkumar.oracle.apps.fnd.importxlsdemo.server.ImportxlsAM

Window Title Import Data From Excel(*.xlsx) through OAF Page Demo
Window

Title Import Data From Excel(*.xlsx) through OAF Page Demo

11. Create messageComponentLayout Region Under Page Layout Region


Right click PageLayoutRN > New > Region

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Attribute Property

ID MainRN

Item Style messageComponentLayout

12. Create a New Item messageFileUpload Bean under MainRN


Right click on MainRN > New > messageFileUpload
Set Following Properties for New Item --

Attribute Property

ID MessageFileUpload

Item Style messageFileUpload

13. Create a New Item Submit Button Bean under MainRN


Right click on MainRN > New > messageLayout
Set Following Properties for messageLayout --

Attribute Property

ID ButtonLayout

Right Click on ButtonLayout > New > Item

Attribute Property

ID Go

Item Style submitButton

Attribute Set /oracle/apps/fnd/attributesets/Buttons/Go

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

14. Create Controller for page ImportxlsPG


Right Click on PageLayoutRN > Set New Controller
Package Name: prajkumar.oracle.apps.fnd.importxlsdemo.webui
Class Name: ImportxlsCO

Write Following Code in ImportxlsCO in processFormRequest


import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import java.io.Serializable;
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;
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Go") != null)
{
DataObject fileUploadData =
(DataObject)pageContext.getNamedDataObject("MessageFileUpload");
String fileName;
try
{
fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
}
catch(NullPointerException ex)
{
throw new OAException("Please Select a File to Upload", OAException.ERROR);
}
BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null,
fileName);
try
{
OAApplicationModule oaapplicationmodule = pageContext.getRootApplicationModule();
Serializable aserializable2[] = {uploadedByteStream};
Class aclass2[] = {BlobDomain.class };
oaapplicationmodule.invokeMethod("ReadExcel", aserializable2,aclass2);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

}
catch (Exception ex)
{
throw new OAException(ex.toString(), OAException.ERROR);
}
}
}

Write Following Code in ImportxlsAMImpl.java


import oracle.jbo.domain.BlobDomain;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public void createRecord(String[] excel_data)
{
ImportxlsVOImpl vo = (ImportxlsVOImpl)getImportxlsVO1();
vo.InsertRecord(excel_data);
getTransaction().commit();
}

public void ReadExcel(BlobDomain fileData) throws IOException


{
try
{
InputStream in = fileData.getBinaryStream();
XSSFWorkbook workbook = new XSSFWorkbook(in);

XSSFSheet sheet = workbook.getSheetAt(0);

int rowsCount = sheet.getLastRowNum();


for (int i = 0; i <= rowsCount; i++)
{
int j = 0;
int colCounts;
Row row = sheet.getRow(i);

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

try
{
colCounts = row.getLastCellNum();
}
catch (NullPointerException e)
{
colCounts=1;
}
String[] excel_data = new String[colCounts+1];

for (int k = 0; k < colCounts; k++)


{
j=j+1;
try
{
Cell cell = row.getCell(k);
switch (cell.getCellType())
{
case Cell.CELL_TYPE_STRING:
excel_data[j] = cell.getRichStringCellValue().getString();
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell))
{
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
excel_data[j] =df.format(cell.getDateCellValue());
}
else
{
int resultVar;
resultVar = (int)cell.getNumericCellValue();
excel_data[j] = Integer.toString(resultVar);
}
break;
case Cell.CELL_TYPE_BOOLEAN:
excel_data[j] = Boolean.toString(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
excel_data[j] = (String)cell.getCellFormula();
break;

default:
excel_data[j] = "";
}

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

}
catch (NullPointerException e)
{
excel_data[j] = "";
}
}
createRecord(excel_data);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}

Write Following Code in ImportxlsVOImpl.java


import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.Row;
public void InsertRecord(String[] excel_data)
{
try
{
executeQuery();
Row row = createRow();

for (int i=1; i < excel_data.length; i++)


{
row.setAttribute("Column" +i ,excel_data[i]);
insertRow(row);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}

15. Congratulation you have successfully finished. Run Your page and Test Your Work

Consider Excel PRAJ_TEST.xlsx with following data --

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Lets Try to import this data into DB Table --

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Category: Oracle
Tags: importing_data_from_xlsx_sheet

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Deploy OAF page


1. Copy all files from local machine to appropriate $JAVA_TOP directory
2. Compile all java files (Controller Files) with command javac <file_name>.java
3, Call java importer to import all xml files
java oracle.jrad.tools.xml.importer.XMLImporter
$JAVA_TOP/prajkumar/oracle/apps/fnd/webui/HelloWorldPG.xml -username apps -password
apps -dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST= <name of
HOST>)(PORT=<port_number>))(CONNECT_DATA=(SID=<SID_NAME>)))" -rootdir
$JAVA_TOP
4. Print Documents to check imported XML page content (Optional)
jdr_utils.printDocument('/prajkumar/oracle/apps/fnd/webui/HelloWorldPG',1000)

Example –
DECLARE
BEGIN
jdr_utils.printDocument('/prajkumar/oracle/apps/fnd/webui/HelloWorldPG',1000);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;

5. Create form function with property "SSWA jsp function" and


webhtml "OA.jsp?page=/prajkumar/oracle/apps/fnd/webui/HelloWorldPG"

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

6. Add function to menu

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

7. Add menu to responsibility

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Bounce Apache Server

Release 12 (Run following command in UNIX)


Stop Server

sh $INST_TOP/admin/scripts/adoacorectl.sh stop

Start Server

sh $INST_TOP/admin/scripts/adoacorectl.sh start

Release 11 (Run following command in UNIX)


Stop Server

sh $COMMON_TOP/admin/scripts/KTPLDEV_trishul/adapcctl.sh stop

Start Server

sh $COMMON_TOP/admin/scripts/KTPLDEV_trishul/adapcctl.sh start

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

How to Enable Personalization link for OAF Pages


Set the values of following profiles to enable Personalization Page link in
OAF Pages

Profile Name Value

FND: Personalization Region Link Enabled Yes

Personalize Self-Service Defn Yes

Disable Self-Service Personal No

After Setting the Values of above profiles

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Controller Extension in OAF


Oracle does not recommend that customers extend controller objects associated with
regions or webbeans in shipped E-Business Suite product pages.
Controller class (oracle.apps.fnd.framework.webui.OAControllerImpl) methods should
effectively be considered private, since their implementation is subject to change. Controller
extensions are therefore not considered to be durable between upgrades.
If it is absolutely essential to handle custom form submit events on a shipped product page,
processFormRequest() is the only method that should be overriden in a controller class,
although the risks outlined above still apply.

Let us try to Extend Controller in OAF Page –


Create one search page as explained in below link –
https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page
In this exercise I am going to extend CO of SearchPG. First lets create CO for SearchPG.
Right Click PageLayoutRN under SearchPG page > Set New Controller
Package Name -- prajkumar.oracle.apps.fnd.searchdemo.webui
Class Name -- SearchCO
Now we will extend this newly created CO under this exercise.
The purpose of this exercise is to modify the VO query of results table. I have changed
theColumn1 and Column2 fields Property Selective Search Criteria as False.
Now when we click on Go button all the records are displaying in the results table and our
OBJECTIVE is to bind the VO query of results table in such a way that in
result Column1 valueval5 and Column2 value val6 should not come as result on click Go
button

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Now for knowing which controller to extend we click on "About This Page" Link and select
Expand All. Here we can see the Name of the controller that we need to extend

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

1. Create a New Workspace and Project


File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarCOExtensionDemo
Automatically a new OA Project will also be created

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Project Name -- COExtensionDemo


Default Package -- prajkumar.oracle.apps.fnd.coextensiondemo

2. Create a New Java Class


Right Click on COExtensionDemo > New > General > Java Class
Name -- ExtendedCO
Package -- prajkumar.oracle.apps.fnd.coextensiondemo.server
Extends -- prajkumar.oracle.apps.fnd.searchdemo.webui.SearchCO

Note -- Give the Name of your Extended Class give its package path and in the extends
property select base class

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Write below logic in ExtendedCO Java Class


package prajkumar.oracle.apps.fnd.coextensiondemo.webui;

import prajkumar.oracle.apps.fnd.searchdemo.webui.SearchCO;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
import prajkumar.oracle.apps.fnd.searchdemo.server.SearchVOImpl;

public class XXItemSearchCO extends ItemSearchCO


{
public XXItemSearchCO()
{
}

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");

//Capturing Go Button ID
String go = queryBean.getGoButtonName();

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

//If its Not NULL which mean user has pressed "Go" Button
if(pageContext.getParameter(go)!=null)
{
// Setting whereClause at Runtime to restrict the query
SearchVOImpl vo = (SearchVOImpl)am.findViewObject("SearchVO1");
vo.setWhereClause(null);
vo.setWhereClause("Column1 <>:1 AND Column2 <>:2");
vo.setWhereClauseParam(0,"val5");
vo.setWhereClauseParam(1,"val6");
}
}
}

4. Attach new controller to SearchPG through personalization


Click on Personalize Page link on top right hand side of your page

Note -- If you are not able to see this link then go through below link –
https://blogs.oracle.com/prajkumar/entry/how_to_enable_personalization_link

Click on Complete View -> Expand All -> Click on personalize icon next to Page Layout

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Now at site level give the path of extended controller as we are extending the controller
atSITE LEVEL
prajkumar.oracle.apps.fnd.coextensiondemo.webui.ExtendedCO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click Apply -> Return to Application

5. Congratulation you have successfully finished. Run Your SearchPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click Go
Note – Record with Column1 value val5 and Column2 value val6 is not coming in result

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Application Module Extension in OAF


Like the Controller extension, AM extension is also not supported by Oracle. However for
some business needs we have to extend it sometimes.
In this exercise we have taken our “Data Entry OAF page” can be found
@https://blogs.oracle.com/prajkumar/entry/insert_data_oaf_page to extend application
module i.e. InsertAM
This AM can be found under below BC4J
packageprajkumar.oracle.apps.fnd.insertdemo.server.InsertAM

Why we are extending AM:-


This InsertAM contains an apply method which subsequently commits the transaction.
public void apply()
{
getTransaction().commit();
}
Our business need is to capture user name and user id at runtime and insert it into a custom
audit table for audit purpose

Here is Audit Table script --


CREATE TABLE xx_audit
( -- -------------------
-- Data Columns
-- --------------------
user_id VARCHAR(50),
user_name VARCHAR(50),
-- -------------------
-- Who Columns
-- -------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

Steps to Extend Application Module (AM)


1. Create a New Application Module (AM)
Right Click on InsertDemo > New > ADF Business Components > Application Module

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Package -- prajkumar.oracle.apps.fnd.insertdemo.server
Name -- ExtendedAM
Extends -- prajkumar.oracle.apps.fnd.insertdemo.server.InsertAM

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Write following code in ExtendedAMImpl.java


import oracle.apps.fnd.framework.OAException;
import java.sql.PreparedStatement;
import java.sql.Connection;
public class ExtendedAMImpl extends InsertAMImpl
{
....

public void apply()


{
java.sql.Date d = getOADBTransaction().getCurrentDBDate().dateValue();
try
{
Connection conn = getOADBTransaction().getJdbcConnection();
String Query = "insert into xx_audit values(:1,:2,:3,:4,:5,:6,:7)";
PreparedStatement stmt = conn.prepareStatement(Query);

stmt.setInt(1, getOADBTransaction().getUserId());
stmt.setString(2, getOADBTransaction().getUserName());

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

stmt.setDate(3, d);
stmt.setInt(4, getOADBTransaction().getUserId());
stmt.setDate(5, d);
stmt.setInt(6, getOADBTransaction().getUserId());
stmt.setInt(7, getOADBTransaction().getUserId());
stmt.execute();
}

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

2. Perform AM Substitution
Double Click on InsertDemo.jpx
Business Components > Substitutions

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. After substitution it will modify *.jpx


In our case it will modify InsertDemo.jpx at project location
i.e. -- D:\xxxx\jdevhome\jdev\myclasses

4. Migrate/ Import the modified jpx


Open Command Prompt and go to following location of your
projectD:\xxxx\jdevbin\oaext\bin

Use this Import Command to import jpx

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

5. Congratulation you have successfully finished. Run Your InsertPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

EO based VO Extension in OAF


In the exercise we have taken “OAF Search Page“can be found @
https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page

We are going to extend SearchVO of SearchPG page. Our business requirement is to


addCreation Date attribute in the results table region

1. Analyze the Page


Click on “About this Page” link to check that which ViewObject is associated with the table
region [ResultsRN]

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Here we can see that results table has SearchVO attached to it. Now click on Business
Component Reference details and check the path of SearchVO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Now click on SearchVO which is an EO based [SearchEO] to check whether it has Creation
Date attribute or not which we want to add

Here we can see that our VO does not have CreationDate attribute.
So for adding this attribute we need to perform VO Extension.
FTP this project from application server and open in JDeveloper

2. Create a New View Object (VO)


Right click on SearchDemo > New > ADF Business Components > View Object
Package -- prajkumar.oracle.apps.fnd.searchdemo.server
Name – ExtSearchVO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Extends -- prajkumar.oracle.apps.fnd.searchdemo.server.SearchVO

The next screen allows the addition or deletion of Entity Objects. No change is required here
for this extension so simply select Next

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

The next pane allows additional attributes to be added or attributes to be removed. In this
case add CreationDate attributes to the selected list

Note -- Please note the new attribute you would be adding will be coming as Transient

Click on Next -> Next

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Modify above SQL statement with below SQL to add new attribute CREATION_DATE

SELECT SearchEO.COLUMN1,
SearchEO.COLUMN2,
SearchEO.ROWID,
SearchEO.CREATION_DATE
FROM XX_SEARCH_DEMO SearchEO

Click on Next -> Next


Generate ExtSearchVORowImpl

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click Finish

Note -- Now as our attribute created as Transient hence to fix this issue we have two options:
1. We need to correct our XML file generated as it is a known error with Jdeveloper
2. Double click on that attribute i.e CreationDate and in the View Object Attribute window,
enter attribute name in 'Expression' column i.e. CreationDate

Lets try first method --


Open your ExtSearchVO.xml file in some notepad editor.
Scroll to bottom of that file
Update

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

with

3. Substitute your New VO with parent VO


Right click on SearchDemo > Project Properties > Business Components > Substitutions
In Available list select SearchVO and in Substitute list select New VO ExtSearchVO and click
on Add and then Ok

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

4. After substitution import *.jpx


In our case it will modify SearchDemo.jpx at project location i.e. --
D:\xxxx\jdevhome\jdev\myclasses
Open Command Prompt and go to following location of your project
D:\xxxx\jdevbin\oaext\bin

Use this Import Command to import jpx

5. Personalize the page to create new item


On SearchPG click on Personalize Page link
Select Complete View Radio Button

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click on Create Item on Table: (ResultTable)

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Set item style as messageStyledText


Set Following Properties
Id – CreationDateId
Data Type -- Date
Prompt – Creation Date
View Instance – ExtSearchVO1
View Attribute – CreationDate

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click Apply > Return to Application

6. Congratulation you have successfully finished. Run Your SearchPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Note -- You can notice page has new Column with name Creation Date

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Entity Object Extension in OAF


In the exercise we have taken “Create Data Entry OAF Page“can be found @
https://blogs.oracle.com/prajkumar/entry/insert_data_oaf_page

We are going to extend InsertEO. Our business requirement is to add Validation on Column1.
The length of entered data in Column1 should be more than 5 Characters.

1. FTP this project from application server and open in JDeveloper

2. Create a New Entity Object (EO)


Right click on InsertDemo > New > ADF Business Components > Entity Object

Name – ExtInsertEO
Package -- prajkumar.oracle.apps.fnd.insertdemo.schema.server
Extends -- prajkumar.oracle.apps.fnd.insertdemo.schema.server.InsertEO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Click on Next - > New from Table

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Include all the attributes of parent EO

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Next -> Next

Check Validation Method check box and Finish

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

3. Add following code in ExtInsertEOImpl.java

import oracle.apps.fnd.framework.OAException;

protected void validateEntity()


{
super.validateEntity();
String column1Value = getColumn1();
if (column1Value.length() < 5)
{
String message = "Length of String" + " " + column1Value + "is less than 5 characters";
throw new OAException(message, OAException.INFORMATION);
}
}

4. Substitute your New EO with parent EO


Right click on InsertDemo > Project Properties > Business Components > Substitutions
In Available list select InsertEO and in Substitute list select New EO ExtInsertEO and click on

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Add and then Ok

5. After substitution import *.jpx


In our case it will modify InsertDemo.jpx at project location
i.e. -- D:\xxxx\jdevhome\jdev\myclasses

Open Command Prompt and go to following location of your project


D:\xxxx\jdevbin\oaext\bin
Use this Import Command to import jpx

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

6. Bounce the server

7. Verify the substitution has applied properly


Run InsertPG page and click on About this Page link

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Expand Business Component References Details


Under that section click on InsertVO which is EO based [it should be ExtInsertEO based]

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

8. Congratulation you have successfully finished. Run Your InsertPG page and Test Your
Work

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OA Framework Best Practices

 AM Retention : Retaining the AM where not required, Not retaining it


wherever required – both are dangerous!!
The AM should be retained whenever you are navigating away from a page
and when you know that there is a possibility to come back to the page again
and data is to be retained. Example : Any navigation link that opens in a new
page or any navigation which has a back button to come back to the initial
page.
The AM should not be retained for two independent pages, especially if they
have common VOs which fetch different result sets. In such cases, retaining
the AM may not remove the cache of VOs and so the result may not be as
expected.

 Setting dynamic whereClause : Avoid setting where clauses dynamically as


far as possible. And when required, set the where clause and where clause
params to null before setting your new where clause. Remember that the
where clause once set will be retained through out. So it‟s a best practice to
make it null wherever it is not required. Creating two VOs is always better
than using a single VO with two dynamic where clauses.

 Fetch Profile Value : Fetching the values like profile , orgId, testFunction
etc can be done in two ways.
1. Fetching it from pageContext.
Syntax : pageContext.getProfile(„XXWHO_ENTITY‟);
2. Write a VO to query the values directly from the data base.
Syntax: SELECT FND_PROFILE.VALUE(‘XXWHO_ENTITY’) FROM DUAL
The first option brings the data from the cache, so it takes time for the
changed values to be reflected in front-end. But the second option is costly
performance wise. So its better to invalidate cache regularly and use the first
option to fetch such kind of values.

 Whenever you are executing a VO or creating rows in a VO in the process


request, do it conditionally. Let it not get executed every time the process
request is called.

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Ex: if(fromPage == “CorrectPage”) {


vo.executeQuery();
}
This avoids duplicate data or data loss whenever your page is rendered from a
dialog page or back button etc.

 If you want any values of your CO to be available in your EO, put those
values in transaction. Do this only if it is very much required. Should not
create unnecessary transactions anywhere. Only get the already existing
transaction object from AM using getTransaction() Method.

 Make it a point to remove all the session parameters and transaction


parameters soon after their utilization. Should be very careful with session
parameters because they result in unnecessary data and it‟s often difficult to
debug.

 Passing too many parameters through hashmap not only effects the
performance but it also effects the UI

 Avoid writing huge code in CO. No business logic should be written in the
CO or AM. Try creating private methods in controller wherever you have
redundant code.

 Create separate interface per module for declaring all your constant variables
rather than hardcoding the values in the code.
Ex : You want to use a lookup name n number of times in your coding.
Instead of hardcoding it everywhere, declare it in your constants interface and
use the constant in your code. Tomorrow, If you have to change the lookup,
you can change it at a single place (in the constants interface) and save time.

 Whenever you have to get or set values of a VO use get/set<Attribute_name>


method instead of getAttribute(index) method. Because the
getAttribute(index) traverses through the entire attributeset in order to find the
required attribute which is a performance issue
Ex: Say, you have an attribute called SelectFlag with attribute index as n . To

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

get the value, use getSelectFlag instead of getAttribute(n).

 HGrid cache: Hgrid is one of the components in OAF which gives major
surprises to the developer everytime. Should be very careful while creating
the viewlink. Remember to clear the cache of the hgrid each time the hgrid is
rendered or the hgrid query is executed.
Syntax : hgridBean.clearCache();
To expand the hgrid upto nth level by default (i.e to expand the tree structure
upto nth child), use the following syntax :
hgridBean.setAutoExpansionMaxLevels(n);
 Better to call sequences from the create method of EO rather than calling
them from custom methods in AM. Infact, set all the default values or who
columns for attributes here only.

 Always reset a VO before iterating it. Especially when getting the values of a
radio button selection etc.
Ex :
vo.reset();
while(vo.hasNext()){
// get handle of the vo‟s current row and perform ur operations;
// break the loop after reaching the last record of the current rowset.
}

 Set any VO‟s where clause and where clause params in VOImpl class rather
than creating directly in CO. This increases reusability and modularity. But
you don‟t have to set any where clause or where clause params and should
directly execute the query, then need not use VOImpl for calling the
executeQuery() method.

 Exception Handling : Proper exception handling is a must. Put your code in


proper try –catch blocks wherever possible.
If your code ,which is in try-catch block, have to throw OAException
anywhere, that will be caught and will not be shown to the user. Hence use
the following statement in the catch block to throw the OAExceptions to the
user :

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

try{
throw new OAException(“APP_CODE”, “ERROR_MSG”);
}catch(Exception _exception) {
throw OAException.wrapperException(_exception);
}
Use the following syntax for logging your exception in the log file
if(pageContext.isLoggingEnabled(4)) {
pageContext.writeDiagnostics(getClass().getName()+”.processFormReque
st”, “Exception Details : “, 4);
}
Do not catch your exceptions wherever they occurred (ex in AM). The
exception must always be thrown back to the calling method . So all the
exceptions must be finally caught in the CO.

 Calling AM methods in CO : Those of you who have used invokeMethod()


in CO to call the AM methods might have observed that it‟s the most tedious
way of calling methods, especially when you have to send serialized
parameters. Importing the AMImpl class in your controller allows you to
access the AM methods directly without the use of invokeMethod() but it
breaks the basic OAF standards coz u r accessing a class in the server package
from a class in the webui package. To overcome the above, the best practice
is to create an Interface of the AMImpl (which neither belongs to server nor
webui) and use this AM Interface in your CO rather than AMImpl class. To
create an interface in Jdeveloper, double click on the AM , select „client
methods‟ and shuttle the required methods to right side. It automatically
creates an interface for you with the selected methods.
Example for getting the object of the interface :
XXWPHomeWorkPlanAM workPlanHomeAM =
(XXWPHomeWorkPlanAM)pageContext.getApplicationModule(webBean).findAp
plicationModule(“XXWPHomeWorkPlanAM

 Understanding Query Regions


When you add a query region to a pageLayout region, OA Framework automatically generates an
oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean which, depending on its configuration, works in
concert with a child table, advanced table or HGrid to implement any combination of simple search, advanced
search and view panels. OA Framework automatically generates buttons as appropriate for toggling between the

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

applicable regions.
 Construction Modes:
There are three construction modes available. In the above example we have
used ‘resultBasedSearch’construction mode. Here is a brief comparison of the three modes.
1] resultsBasedSearch:
 OA Framework automatically renders both the Simple and Advanced search regions based on the
designated queryable items in the associated table.
 The search regions automatically include both a Go and a Clear button.
 OA Framework automatically executes the underlying search when the user selects the Go button.
2] autoCustomizationCriteria:
 OA Framework automatically renders both the Simple and Advanced search regions based on the
corresponding Simple search and Advanced search regions that you define and specify as named
children of the query region.
 The search regions automatically include a Go button. In addition, the Advanced search region includes a
Clear button.
 OA Framework automatically executes the underlying search when the user selects the Go button.
However, developers must explicitly define mappings between items in the Search panel and items in the
table region.
3] none
 The Search regions are rendered based on the Simple Search and Advanced Search regions that you
define and specify as named children of the query region.
 You must implement your own Go button in this mode.
 The underlying search must be executed by the developer.

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

OAException Message and Dialog Page in OA Framework

You can use OAException (or any of its subclasses) to display a message on an OA Framework page and the OA
Framework automatically displays an error message at the top of the current page.
You can display the following standard kinds of messages at the top of a page:
 Error
 Warning
 Confirmation
 Information
You can explicitly display a message box of any type using the following code in your controller.

1 OAException message = new OAException("You cannot create a new change order


when a Draft version already exits.",OAException.ERROR);
2 pageContext.putDialogMessage(message);
Here you need to construct an oracle.apps.fnd.framework.OAException object and set the kind of message you
want (other options are OAException.WARNING, OAException.INFORMATION and
OAException.CONFIRMATION). Then you can simply identify this exception for display when the page renders by
calling the OAPageContext.putDialogMessage() method.

If — after you call putDialogMessage() in your processFormRequest() method — you want to forward to the current
page or another page and display the message at the top of the new target page, you need to call the appropriate
oracle.apps.fnd.framework.webui.OAPageContext forwardImmediately*() method. The OA Framework immediately
stops processing the page and issues a forward before displaying the messages.
You can register or throw multiple exceptions; the OA Framework combines them into a single message box using
the following rules:
 Since an error is more important than a warning, the message box is titled “Error” if both errors and
warnings exist.
 Confirmations and errors cannot be shown together. In this case, the OA Framework simply ignores the
confirmation message(s).
 You can, however, show confirmations with warnings. The message box is titled “Confirmation,” and it
contains both types of messages.
Show the Exception Message on a Dialog Page
You can display an exception as a message in a dialog page using the APIs in the
oracle.apps.fnd.framework.webui.OADialogPage class and oracle.apps.fnd.framework.webui.OAPageContext
interface.

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

The OADialogPage class holds properties for the generic dialog page. To create a dialog page object, first use the
constructors to instantiate the basic properties, then use the setter methods provided in the class to set additional
properties.
To navigate (redirect) to a dialog page, use the OAPageContext.redirectToDialogPage methods. The
OAPageContext interface contains the context and state information specific for a client request.
01 // To Diaplay the Exception on a Dialog page

02 OAException message = new OAException("You cannot create a new change


order when a Draft version already exits.");

03 OADialogPage dialogPage = new OADialogPage(OAException.ERROR,


message, null,"",null);
04
05 dialogPage.setOkButtonToPost(true);
06 dialogPage.setOkButtonLabel("Ok");
07
08 dialogPage.setPostToCallingPage(true);
09 java.util.Hashtable formParams = new java.util.Hashtable(1);
10 dialogPage.setFormParameters(formParams);
11 pageContext.redirectToDialogPage(dialogPage);
If you want 2 buttons (Say Cancel and Ok), then put “” instead of null in the OADialogPage dialogPage = new
OADialogPage line.

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

Deploying OAF Personalizations Using the Import/Export Command


Line Tools
After personalizing and testing framework pages in a Development instance, you may wish to automate the transfer
of these changes to another instance, rather than manually re-doing them all again. This objective can be achieved
by exporting the personalizations from the Development instance, then importing them to a different instance or
instances
You can either use the GUI interface in “Functional Administrator” (Personalization tab) to transfer personalizations,
or can invoke the XMLImporter/XMLExporter commands directly from the command line. The Export tool allows
you to export a package or xml file (along with translation information) from the MDS repository of a database
instance to a .xml file (or .xlf file for translations). The command line Export tool is necessary if you wish to perform
bulk translations of personalization documents.
This post provides the below detailed steps how to transfer personalizations from one instance to others using the
XMLImporter/XMLExporter tool.
1. Get Document Name
Go to the page you want to copy the personalization from and click the “about this Page” link at the bottom of the
page. You will see the page name with full path which starts with /oracle/apps/<prod>.
Ex: /oracle/apps/icx/por/wf/webui/ReqLinesNotificationsRN
2. Get the Personalization Document info
Run the following command in TOAD or other tools as APPS user
1 set serveroutput on
2 exec jdr_utils.listCustomizations('<full document name from step 1>');
Example:
1 set serveroutput on
execjdr_utils.listCustomizations('/oracle/apps/icx/por/wf/webui/ReqLinesNot
2
ificationsRN');
Output:
anonymous block completed
/oracle/apps/icx/por/wf/webui/customizations/site/0/ReqLinesNotificationsRN
Note: If there are multiple records returned by this command, you will need to use export/import each item
individually that you wish to export. You may also find there are records returned for seeded personalizations
provided by Oracle which do not need to be exported.
3. Use XMLExporter to export personalization document
java oracle.jrad.tools.xml.exporter.XMLExporter <personalization document
1
from step #2> \
2 -username "<username>" -password "<password>" \
-dbconnection
3 "(description=(address_list=(address=(protocol=tcp)(host=<host>)(port=<port
)))(connect_data=(sid=<sid>)))" \
4 -rootdir "<output directory>"
Example:
1 java oracle.jrad.tools.xml.exporter.XMLExporter \

Copyright © 2013, AppsLead. All rights reserved


Contact Us: 002 – 010 900 160 23
002 – 0100 62 62 837

/oracle/apps/icx/por/wf/webui/customizations/site/0/ReqLinesNotificationsRN
2
-username apps -password w3lcome123 \
-dbconnection
3 "(description=(address_list=(address=(protocol=tcp)(host=myhost)(port=12345
)))(connect_data=(sid=dev)))" -rootdir "$XXSCM_TOP/install" \
Here one file named ReqLinesNotificationsRN.xml will be created in the below path:
XXSCM_TOP/install/oracle/apps/icx/por/wf/webui/customizations/site/0. Open the file and you will able to view the
personalizations that you have done.
4. Use XMLImporter to import personalization document
Run the below command in the Instance where you want to import your personalization.
1 java oracle.jrad.tools.xml.importer.XMLImporter \
2 <full path of the file you want to import> \
3 -username "<username>" -password "<password>" \
-dbconnection
4 "(description=(address_list=(address=(protocol=tcp)(host=<host>)(port=<port
>)))(connect_data=(sid=<sid>)))" -rootdir "<top level directory>" \
5 -rootPackage "/oracle/apps/<prod>"
Example:
1 java oracle.jrad.tools.xml.importer.XMLImporter \
2 $XXSCM_TOP/install/ReqLinesNotificationsRN.xml \
3 -username apps -password w3lcome123 \
-dbconnection "(description=(address_list=(address=(protocol=tcp)(host=
4 myhost)(port=12345)))(connect_data=(sid=dev)))" -rootdir
"$XXSCM_TOP/install" \
5 -rootPackage "oracle/apps/icx/por/wf/server"

Copyright © 2013, AppsLead. All rights reserved

You might also like