OAF Training
OAF Training
Page 1 of 86
Hitachi Consulting, Hyderabad
TABLE OF CONTENTS
Page 2 of 86
Hitachi Consulting, Hyderabad
What is OA Framework
Prerequisites
• Basics of Java or OOPs (Object Oriented Programming) is needed.
• Basics of XML is needed.
• Understand the MVC Architecture
• Have Oracle apps 11i or higher version to play around with.
Page 4 of 86
Hitachi Consulting, Hyderabad
Page 5 of 86
Hitachi Consulting, Hyderabad
Model:
1. Model is Data
EO (Entity Object)
VO (View Object)
AM (Application Module)
Page 6 of 86
Hitachi Consulting, Hyderabad
View:
View is User Interface.
Implemented using an Oracle technology called UIX.
Controller:
Responds to user actions and directs application flow.
Model objects like EO and VO can't be accessed directly from theController
Class, except AM.
Controller Contains following methods
ProcessRequest: Fires when OAF page loads for the first time.
ProcessFormRequest: Fires when user submits the page.(Ex: clicking
SUBMIT button).
ProcessFormData: This method is hidden in the controller.Fires for
populating data from screen to view objects.
Page 7 of 86
Hitachi Consulting, Hyderabad
Page 8 of 86
Hitachi Consulting, Hyderabad
Controller
Controller Class
AM
Model
VO EO
Database
The above Figure shows how model ,view and controller interacts with each other.
Page 9 of 86
Hitachi Consulting, Hyderabad
Page 10 of 86
Hitachi Consulting, Hyderabad
Why OA Framework
Page 11 of 86
Hitachi Consulting, Hyderabad
Environment:
Release 12.0
12.0.5 (No new ATG code released) No new JDev patch required
Page 12 of 86
Hitachi Consulting, Hyderabad
Page 13 of 86
Hitachi Consulting, Hyderabad
Obtain the FND database connection (.dbc) file from the system
administrator who installed the OA Framework database where you want to
do your development. Place this file in the
<JDEV_USER_HOME>\dbc_files\secure directory.
Page 14 of 86
Hitachi Consulting, Hyderabad
10.Select Tutorial.jpx in the System - Navigator pane, then select Edit Tutorial
from the context menu. Verify that the Connection Name is set correctly.
Select Apply, then OK.
11.Repeat Steps 3 - 7 for the LabSolutions.jpr project.
12.Expand the Connections node in the JDeveloper System Navigator and then
expand the Database node. Right-click on the Database node and select New
Connection... to open the Connection Wizard. Follow the JDeveloper
instructions to define a new database connection for the Oracle Applications
13.database identified by the DBC file you selected above.
14.Select the Tutorial.jpr project In the System Navigator. Right-click and
select Edit Business
15.Components Project....
16.Select the Connection option in the Business Components Project Wizard
and set the Connection
17.Name to the connection you just defined. Select OK to save your changes.
18.Repeat steps 9 - 11 for the LabSolutions.jpr project.
Page 15 of 86
Hitachi Consulting, Hyderabad
JDeveloper Structure
Below figure show the standard component structure in jdeveloper
Level 1: OAWorkspacte.jws
Level2: OAProject.jpr
Page 16 of 86
Hitachi Consulting, Hyderabad
AM –Application Module+
< CutomTop>.oracle.apps.<APPL_TOP_NAME>.webui contains
PG -Page
Top Most level is OAWorkspace which contains Projects. Projects contains the
Entity objects ,view objects and Application Module components.
Page 17 of 86
Hitachi Consulting, Hyderabad
After completing this exercise, you should have learned how to:
• Create an Oracle Applications (OA) JDeveloper10g workspace and project.
• Configure a project to enable Developer Mode testing and diagnostics.
• Use the JDeveloper10g OA Extension to create a very simple page.
• Create a controller and associate it with a region.
• Handle a submit button press action (an HTTP POST request).
• Run a page in regular and debug modes.
The page does nothing other than display a message when you enter a value in the
field and click the Go button. Your final layout looks like the following:
Page 18 of 86
Hitachi Consulting, Hyderabad
Step 1. Create a New OA Workspace and Empty OA Project with the New...
Dialog.
Step 2. Set Run Options in OA Project Settings
Step 3. Create the OA Components Page File
Step 4. Modify the Page Layout (Top-level) Region
Step 5. Create the Second Region (Main Content Region)
Step 6. Create the First Item (Empty Field)
Step 7. Create a Container Region for the Go Button
Step 8. Create the Second Item (Go Button)
Step 9. Save Your Work
Step 10. Run Your Page Using the Run Option
Step 11. Add a Controller
Step 12. Edit Your Controller
Step 13. Build Your Controller
Step 14. Test Your Work Using the Run Option
Select File > New... to open the New... dialog (shown in the following diagram).
This dialog is also called the New Object Gallery.
Page 19 of 86
Hitachi Consulting, Hyderabad
Choose General > Workspace Configured for Oracle Applications from the
New... dialog, or highlight Workspaces in the Navigator and choose New OA
Workspace... from the context menu (right mouse button
menu that changes depending on the context). You'll be prompted to create an OA
workspace. Verify that the default workspace directory name points to your own
<JDEV_USER_HOME>\myprojects directory, as shown in the following diagram.
Modify the workspace file name as well (any name is okay for a workspace, such
as HelloWorldOAWorkspace.jws).
Check the Add a New OA Project check box.
Page 20 of 86
Hitachi Consulting, Hyderabad
After you click OK, you will see the Oracle Applications Project Wizard.
In Step 1 of the wizard, verify that the default project directory name points to your
own JDEV_USER_HOME\myprojects directory, as shown in the following
diagram.
Page 21 of 86
Hitachi Consulting, Hyderabad
In Step 2 of the wizard, verify that the XML Path points to your own
JDEV_USER_HOME\myprojects directory, as shown in the following diagram.
You can include additional directories in the XML Path field if you have files in
your project that do not reside under your myprojects directory. For your Hello
World project, you do not use the Repository for metadata in the database (the
Hello World example uses only the XML files). In regular development work,
where you use standard components that have been imported into the Repository,
you would check the Use Repository for Design Time check box and
provide connection information in Step 2.
Page 22 of 86
Hitachi Consulting, Hyderabad
In Step 3 of the wizard, adjust the runtime connection information, if necessary, for
the database and Oracle Applications username, password, and responsibility you
are using (it must be a valid user and responsibility for your installation).
Page 23 of 86
Hitachi Consulting, Hyderabad
Page 24 of 86
Hitachi Consulting, Hyderabad
To verify that your project includes all of the appropriate libraries, paths and other
settings, select your project in the Navigator and choose Project Settings... from the
context menu, or double-click on your project.
Select the Common > Oracle Applications > Run Options settings page. Select
OADeveloperMode and OADiagnostic, and move them to the On Options List.
You should always have these two modes turned on during development. The
other modes are generally used for testing towards the end of developing your page
Within your new workspace, select your new project (your .jpr file). To add an OA
Components page file to your project, choose New... from the context menu or use
File > New... on the main menu to open the New... dialog.
Page 26 of 86
Hitachi Consulting, Hyderabad
Select Web Tier > OA Components in the Categories column. Then select Page,
and press OK as shown in the following diagram:
You will then see a dialog box that asks for the name and package file for your
new page. This dialog box is shown in the following diagram:
Name your page XXHelloWorldPG. Your page name cannot include any spaces.
Page 27 of 86
Hitachi Consulting, Hyderabad
Your initial page structure appears in the Structure window as shown below, with
an initial pageLayout region called region1, and a folder called pageLayout
Components. The pageLayout Components folder contains a standard corporate
branding image ("Oracle") that you cannot change (though you can add other
elements).
Page 28 of 86
Hitachi Consulting, Hyderabad
Page 29 of 86
Hitachi Consulting, Hyderabad
Page 30 of 86
Hitachi Consulting, Hyderabad
JDeveloper creates your top-level page layout region for you automatically when
you create your page.If the Property Inspector is not already open, select View >
Property Inspector from the main menu. You can alternate between the
alphabetical list of properties and the categorized list by clicking on the Categories
button at the top of the Property Inspector (shown above with categories enabled).
• Set the following properties for your page layout region:
• Set the ID property to PageLayoutRN.
• Verify that the Region Style property is set to pageLayout.
• Verify that the Form property is set to True.
• Verify that the Auto Footer property is set to True.
• Set the Window Title property to <your name>: Hello World Window Title.
This becomes the
• window title for the page.
Page 31 of 86
Hitachi Consulting, Hyderabad
• Set the Title property to <your name>: Hello World Page Header. This
becomes the page
• header for the page (it appears under the blue bar).
• Set the AM Definition property to.
Page 32 of 86
Hitachi Consulting, Hyderabad
Create your second region under the page layout region by selecting the page
layout region in the Structure window and choosing New > Region from the
context menu.
This region is merely going to provide a container for your items and ensure that
the items are properly indented. Set the following properties for your second
region:
• Replace the default value in the ID property with MainRN.
• Set the Region Style property to messageComponentLayout (this provides
an indented single- or multiple-column layout for the child items of the
region).
Page 33 of 86
Hitachi Consulting, Hyderabad
Page 34 of 86
Hitachi Consulting, Hyderabad
Create your first item under the second region (main content region) by selecting
the second region in the Structure window and choosing New > messageTextInput
from the context menu.
• Set the following properties for your item:
• Set the ID property to HelloName.
• Verify that your Item Style property is set to messageTextInput (this style
provides a text label and an input field).
• Set the Prompt property to Name (in the later labs, you will use an attribute
set to set the prompt).
• Set the Length to 20.
• Set the Maximum Length to 50.
If you want to, you can run your page at this point.
Page 35 of 86
Hitachi Consulting, Hyderabad
Page 36 of 86
Hitachi Consulting, Hyderabad
Page 37 of 86
Hitachi Consulting, Hyderabad
Page 38 of 86
Hitachi Consulting, Hyderabad
Verify that the Prompt property is now set to Go (this is your button label,
inherited from the attribute set). If you want to, you can run your page at this point.
Save your work. Using the menu choice File > Save All will save your metadata
changes to an XML file as well as save all your other file changes (such as to a .jsp
or .java file).
Page 39 of 86
Hitachi Consulting, Hyderabad
Tip: Though it usually will not be written out as a separate step in the exercises,
you should save your work frequently.
You can try out your page using the Run option on the context menu.
If you are using a database other than what you already have in your project
settings, you will need to modify the Runtime Connection project settings by
selection your project file and choosing Project Settings ... from the main menu.
Specifically, you must use a combination of Username, Password, (Responsibility)
Application Short Name and Responsibility Key that is valid for you database to
enable your session to log in.
Page 40 of 86
Hitachi Consulting, Hyderabad
You can use the Run option in the context menu to test your page in a standard
browser. This option allows you to test your layout as well as functionality such as
handling button presses. Select your page or page layout region in the Structure
window, and choose Run from the context menu. Alternatively, you can select
your page in the Navigator window, and choose Run <page name> from the
context menu.
Page 41 of 86
Hitachi Consulting, Hyderabad
You may have to wait a few minutes or more before you see your page in a
separate browser window (it often takes longer the first time).
If your page does not appear after a few minutes, or gives errors, check the
messages in the Log window. See the Hello, World! Troubleshooting Guide or the
Oracle9i JDeveloper OA Extension FAQ. Your page should look like the
following picture (with your own name in the page header and window title). You
should see your page header, your Name field, and your Go button, along with
global links and buttons (some global buttons may not appear depending on profile
option settings). You may or may not see a Personalize Region link below your
page header, depending on profile option settings. Do not personalize this page, as
personalizations are data driven and you will affect anyone else building the Hello
World page on the same
database.
Page 42 of 86
Hitachi Consulting, Hyderabad
Each time you make changes to your layout (by adding regions or items,
modifying properties, or changing code), you must run your page again to see your
changes. If the Run process seems to hang for several minutes after you have
already run your page previously, you may need to terminate the OC4J server
using the Run > Terminate > Embedded OC4J Server main menu option, and then
run again.
Page 43 of 86
Hitachi Consulting, Hyderabad
Page 44 of 86
Hitachi Consulting, Hyderabad
Add the following line as the last line of the import section to make the OA
Framework OAException routines available:
import oracle.apps.fnd.framework.OAException;
Note that you can sort your imports using the context menu in the code editor
(Organize Imports > Sort Imports) as shown in the following picture:
Page 45 of 86
Hitachi Consulting, Hyderabad
Page 46 of 86
Hitachi Consulting, Hyderabad
Page 47 of 86
Hitachi Consulting, Hyderabad
Save your work, then test it using the Run option. Type something into your field
and then click the Go button.You should see the your page with an informational
message that contains what you typed into the field, as shown:
Page 48 of 86
Hitachi Consulting, Hyderabad
Lab Goals
Create a page include two items one for User Name and Responsibility
Name
Item style as message style text.
Create the controller.
Display the username and responsibility name while loading the page, so
select process request.
Get the username and responsibility name from page context.
Initialize message style text item and import the same.
Validate the two fields and assign the same to the fields.
Page 49 of 86
Hitachi Consulting, Hyderabad
Page 50 of 86
Hitachi Consulting, Hyderabad
Page 51 of 86
Hitachi Consulting, Hyderabad
Page 52 of 86
Hitachi Consulting, Hyderabad
Page 53 of 86
Hitachi Consulting, Hyderabad
Code in controller
String username=pageContext.getUserName();
OAMessageStyledTextBean
mstuser=(OAMessageStyledTextBean)webBean.findIndexedChildRecursive("User
Name");
mstuser.setValue(pageContext,username);
String Resname=pageContext.getResponsibilityName();
OAMessageStyledTextBean
mstres=(OAMessageStyledTextBean)webBean.findIndexedChildRecursive("Resp
onsibilityName");
mstres.setValue(pageContext,Resname);
Page 54 of 86
Hitachi Consulting, Hyderabad
Lab Goals
Page 55 of 86
Hitachi Consulting, Hyderabad
Page 56 of 86
Hitachi Consulting, Hyderabad
Page 57 of 86
Hitachi Consulting, Hyderabad
Page 58 of 86
Hitachi Consulting, Hyderabad
Page 59 of 86
Hitachi Consulting, Hyderabad
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Go")!=null)
String firstname=pageContext.getParameter("FirstName");
OAMessageTextInputBean
mti=(OAMessageTextInputBean)webBean.findChildRecursive("SecondName");
mti.setValue(pageContext,firstname);
Page 60 of 86
Hitachi Consulting, Hyderabad
Result:
Page 61 of 86
Hitachi Consulting, Hyderabad
After completing this exercise, you should have learned how to:
Create a typical search page including an OAQueryBean search region and a
results table.
Enable "selective search criteria" to prevent blind queries.
Create a List of Values (LOV).
Create a root UI application module and enable passivation.
Create a BC4J package.
Create a plain SQL view object.
For this exercise, you'll be implementing a simple search and results page.
Page 62 of 86
Hitachi Consulting, Hyderabad
Page 63 of 86
Hitachi Consulting, Hyderabad
Page 64 of 86
Hitachi Consulting, Hyderabad
Page 65 of 86
Hitachi Consulting, Hyderabad
Note that passivation is not fully supported in release 11.5.10 production; this is
included for preview purposes.
Note: When you are ready to build your own applications, you can learn more
about passivation in the OA Framework Developer's Guide advanced topic OA
Framework State Persistence Model (Passivation). The related Model Coding
Standard M8 has an important note stating that the RETENTION_LEVEL
property described below should not be set to MANAGE_STATE unless you are
ready to fully implement and certify your page for passivation support.
Warning: you must match the case and spelling exactly as shown.
Select the Add button.
Select the Apply button.
Select the OK button to close the Application Module Editor window.
Tip: Most of the BC4J wizards allow you to resize the wizard window, even
though there may not be visible resize controls. This is helpful for viewing long
values and SQL statements.
Page 67 of 86
Hitachi Consulting, Hyderabad
Page 68 of 86
Hitachi Consulting, Hyderabad
Page 69 of 86
Hitachi Consulting, Hyderabad
Step 2.9 Add Your View Object to the Root UI Application Module
View objects can be used only within the context of a containing application
module. Before you can use the EmployeeSearchVO in your page, you must add
it to the page's root UI Application Module.
Select the EmployeeAM in the Navigator pane, right-click and select Edit
EmployeeAM... from the context menu to open the Application Module
Editor.
Navigate to the Data Model page.
Select the EmployeeSearchVO view object in the Available View Objects
list and shuttle it to the Data Model list.
Tip: Take careful note of the default View Instance name that BC4J creates when
you add your VO to the selected AM (BC4J creates this name by appending a "1"
to your VO name). Leave it or change it, your choice (we suggest leaving the
default value as is). In either case, know what the value is before creating your
Results table region in the next task.
Page 70 of 86
Hitachi Consulting, Hyderabad
You'll see how to enable the user-personalizable Views panel, the Simple Search
panel, and the Advanced Search panel without explicitly creating the UIs for these
regions. In the next task, you will change from a "results-based" search to an "auto
customization criteria" search so you can take a bit more control of the UI that
displays in the Search region.
Page 71 of 86
Hitachi Consulting, Hyderabad
Property Value
ID QueryRN
Region Style query
Construction Mode resultsBasedSearch
Include Simple Panel True
Page 72 of 86
Hitachi Consulting, Hyderabad
Property Value
ID ResultsTable
Rendered True
Records Displayed 10
Width 100%
Page 74 of 86
Hitachi Consulting, Hyderabad
Note that you don't have to implement the query; the OA Framework implements
this for you automatically based on the table items that you identified with the
Search Allowed property. Furthermore, the OA Framework creates a Search UI
based on the data and item types of the Search Allowed items.
Page 75 of 86
Hitachi Consulting, Hyderabad
Page 76 of 86
Hitachi Consulting, Hyderabad
Page 77 of 86
Hitachi Consulting, Hyderabad
Select this item, and set or verify its properties as follows (note that some
properties are set by the attribute set, so you should specify this first):
Property Value
ID SearchEmpName
Item Style messageTextInput(you will change this
to an LOV field a bit later
Selective Search Criteria True
Data Type VARCHAR2
Maximum Length 240
CSS Class OraFieldText
Length 40
Property Value
ID SearchEmpNum
Item Style messageTextInput
Selective TRUE
Search
Criteria
DataType NUMBER
Maximum 15
Length
Prompt Employee Number
CSS Class OraFieldText
Length 15
Page 78 of 86
Hitachi Consulting, Hyderabad
Step 5.5 Create Search Mappings Between Your Name / Number Items and
the ResultsTable
The OA Framework uses the mappings that you define between your custom
search items and columns in the ResultsTable to automatically handle the query
when the user selects the Go button.
Select the query bean or the query Components folder in the Structure pane,
right-click and choose New > simpleSearchMappings from the context
menu.
Select the default mapping created under the simpleSearchMappings and set
its properties to the following:
Property Value
ID EmpNameMap
Search Item SearchEmpName
Results Item EmpName
Property Value
ID EmpNumMap
Search Item SearchEmpNum
Results Item EmpNum
Page 79 of 86
Hitachi Consulting, Hyderabad
Step 6.1 Create the BC4J Package for Your LOV-Related Model Objects
All LOV view objects should be created in a common product package.
Page 80 of 86
Hitachi Consulting, Hyderabad
Select the Next button until you get to the Java page.
In the Java page, deselect the Generate Java File for View Object Class:
EmployeeNamesVOImpl (you don't need to add any code to this view
object). Do select the Generate Java File for View Row Class:
Page 81 of 86
Hitachi Consulting, Hyderabad
Page 82 of 86
Hitachi Consulting, Hyderabad
DO NOT select the Use this as Application Module Definition for this region
checkbox.
Page 84 of 86
Hitachi Consulting, Hyderabad
Select the default LOV mapping, ID'ed as lovMap1, and set the following
properties:
Change the LOV Region Item property by selecting EmpName field from
the poplist.
Change the Return Item property by selecting SearchEmpName field from
the poplist.
Change the Criteria Item property by selecting SearchEmpName field from
the poplist.
Right-click lovMappings in the Structure panel, and select New > lovMap
from the context menu.
Select the default LOV mapping, ID'ed as lovMap2, and set the following
properties:
Page 85 of 86
Hitachi Consulting, Hyderabad
Page 86 of 86