OA Framework Intro
OA Framework Intro
Objectives
– Understand some Terminologies
– Understand OA Framework Overview
– Implement a simple Hello World example
– Understand why MVC is used in OA Framework
– Understand the Model, the view & the controller
– Understand Servlets, JSP, & J2EE & how they relate
to MVC Design pattern
– Understand the key concepts of OAF
– Implement a full example in JDeveloper
Terminology
• MVC : Model – View – Controller
• Servlets : Java-based Web Application Server
• JSP : JavaServer Pages
• J2EE : Java 2 Enterprise Edition
• JDBC : Java DataBase Connectivity
• UIX : User Interface for XML
• MDS : MetaData Services
• OAF : Oracle Applications Framework
• Beans : Reusable Components
Terminology
• BC4J : Nothing but a grouping of objects that are developed to achieve a business
functionality.
• Entity Objects – EO : A java class that manages DML and validations on the base
table
• View Object – VO : A set of Java/XML files that represent a query on a table or sets
of tables. A default VO that is based on EO will do select * from table[of EO]
• Application Module – AM : Manages the Database transaction state. Hence all the
DB Related operations from Web Page must be routed via AM.
Note:- VO's are attached to AM. This means that AM interacts with EO via VO.
• OA Page : A web page using which user interacts with system.
• OA Page Regions : Different sections with in the OA Page, to logically group similar
items. Region can be attached to the AM, hence as soon as the Page Region gets
loaded, the AM attached to that page will be instantiated by OA Framework. Given
that VO's are attached to AM, VO's attached to the AM will also be instantiated by
OA Framework when AM gets instantiated.
• Controller :A java class that gets called when the "OA Page" is loaded onto the
screen to display. This java class is also called then user fires an action on the page,
for example Clicking on a button.
OA Framework Overview
• Oracle Application Framework is the Oracle
Applications development and deployment platform
for HTML-based business applications.
• OA Framework consists of a set of middle-tier
runtime services and a design-time extension to
Oracle JDeveloper called Oracle Applications
Extension (OA Extension).
OAF Architecture
– Written in Java
– Uses JDeveloper 10g with OA Extension
– Uses the following components
• Business Components for Java (BC4J)
• User Interface XML (UIX)
• Application Object Library for Java (AOL/J)
• OA Framework
• Metadata Services (MDS)
• Caching Framework
• Oracle JDBC 10g
The OA Framework Architecture
Client Application Server Data Server
Browser Listener
BC4J
Servlet Engine
Metadata
Repository
UIX
OA Extension (MDS)
• Controller – OA Controller
responds to user actions,
OA Controller directs application flow
What’s in BC4J(Model)?
– BC4J is the M (Model) layer of the MVC pattern.
– Includes the following basic BC4J components.
• Application Modules (AMs)
– A container for related BC4J objects
– All application modules that you create subclass the
oracle.apps.fnd.framework.server.OAApplicationModuleImpl
• Entity Objects (EOs)
– Encapsulate business rules
– Most entity objects that you create subclass the
oracle.apps.fnd.framework.server.OAEntityImpl
• View Objects (VOs)
– Present data to the Framework page
– All view objects that you create subclass the
oracle.apps.fnd.framework.server.OAViewObjectImpl
What’s in UIX(View)?
– UIX is part of the V (View) layer of the MVC pattern.
– UIX underlies the OA Framework UI components.
– Using both OA Framework and UIX allows OA Framework
applications to have a consistent E-Business Suite look and
feel.
– Includes specific simple and complex UI components, like
the following:
• Fields
• Buttons
• Tables
• LOVs
• and others
What’s in OA Controller?
• The controller responds to user actions and directs
application flow.
• The controller class is where you define how the web
beans behave. Specifically, you write controller code
to:
– Manipulate/initialize the UI at runtime (including any
programmatic layout that you are unable to do
declaratively) and
– Intercept and handle user events like button presses
• All controllers that you create subclass
oracle.apps.fnd.framework.webui.OAControllerImpl
The Model
Basics of the Model
Basics of the Application Module
Basics of Entity Objects
Basics of View Objects
Vital Concepts
An example
Basics of the Model
• 'Client' / 'Server' Code Separation (MVC reason for existence)
• A typical JSP application has 3 physical tiers:
– The browser (the client where our HTML renders and users interact
with the UI)
– The web application server (the middle tier where our UI web bean
hierarchy is constructed and our application business logic executes)
• Client classes (View and Controller code) drive the HTML user interface
• Server classes (Model code) supports any client (not just OA Framework)
user interfaces
– The database server
• Model code should never reference controller code directly
• Never reference/import any server-side implementation
classes or interfaces on the client-side
For example, do not call methods on an
oracle.apps.fnd.framework.OADBTransaction in your UI controller.
Basics of the Model
• If you need the server code to do some work for you, always
route your calls through the root application module using
the generic "remoteable" invokeMethod() method on the
oracle.apps.fnd.framework.OAApplicationModule interface
Business Component (BC4J) Packages
• While not formally a BC4J component, every BC4J
component must belong to a BC4J package.
• BC4J packages contain the following:
– The naming/pathing structure for the BC4J components it
stores.
– The database connection associated to the package for your
development environment.
– Is mostly used for showing the relationship amongst related
BC4J components by storing related components together, and
then using a standardized naming structure to highlight the
relationship.
BC4J Package Naming Standards
– BC4J packages also correspond to directory paths.
– EO-related (business logic) .java and .xml files in
oracle.apps.<application shortname>. <module>.schema.server
OrdersByAO
CustomerEO OrderEO
Association
Source Destination
View Links
• A view link is an active link between view objects.
• You can create view links by providing the following:
– Source and destination views
– Source and destination attributes
• Use a View Link to create a Master-Detail relationship
between view objects.
– Allows dynamic synchronization between parent and child VO
– Child rowset is refreshed when the current parent row
changes
Order4ItemVL
InvItemVO LineItemVO
Link
Source view Destination
object view object
Entity Experts
• Simple common code or, more commonly, validation
routines that can be called by other EOs that avoids
the overhead of instantiating an entire EO.
• For example, a PurchaseOrderHeaderEOImpl class
doesn't want to instantiate a whole SupplierEOImpl
class just to find out if the supplierId foreign key it's
about to set is valid. Instead, it calls an
isSupplierIdValue(Number supplierId) method on the
supplier's entity expert singleton -- a much lighter
weight operation.
Validation AMs and Validation VOs
– Validation VOs (VVOs): Allows simple SQL statements to
be executed at the entity-layer. Most commonly, these
are SELECT statements done to validate data.
– Validation AMs (VAMs): VOs must be contained within
AMs. VAMs are the containers for VVOs.
• For example, a purchase order header has many lines. Each line
is assigned a unique line number. This number is defined as the
current maximum line number for the entire purchase order +
1. At runtime, we need to query the database to find out what
the maximum line number is for a given purchase order header:
» SELECT MAX(LINE_NUMBER) FROM
FWK_TBX_PO_LINES WHERE HEADER_ID = :1;
The Controller (Servlet)
• The controller responds to user actions and directs application
flow.
• You write controller code to:
– Manipulate/initialize the UI at runtime (including any
programmatic layout that you are unable to do declaratively)
– Intercept and handle user events like button presses
• Controller classes subclass OAControllerImpl
• OAPageBean is the main OA Framework page processing class.
• Controllers can be associated with the view at the region level
• There are methods in the Controller class to handle GET
(processRequest) and POST (processFormRequest &
processFormData) requests.
Request Handling
• When the browser issues an OA.jsp request for one of your pages:
1. The user is validated
2. The OAPageBean (the main OA Framework page processing class) evaluates
request parameters to figure out if it is dealing with an HTTP POST or a GET.
• Handling a GET Request:
1. The OAPageBean calls processRequest() on the page's top-level pageLayout bean
along with the entire web bean hierarchy
2. The oracle.apps.fnd.framework.webui.OAPageBean gives the web bean hierarchy to
UIX to render and send to the browser.
• Handling a POST Request
1. The OAPageBean checks to see if the web bean hierarchy is in memory. If not, it
recreates the hierarchy as described in the GET processing above.
2. The OAPageBean calls processFormData(OAPageContext pageContext, OAWebBean
webBean)on all the beans in the hierarchy
3. If no exceptions are thrown during the processFormData() phase, OAPageBean calls
processFormRequest(OAPageContext pageContext, OAWebBean webBean) on all
the beans in the hierarchy
4. If no JSP forwards or page redirects were issued -- or exceptions were thrown in
processFormRequest() -- then the page is refreshed.
OAPageContext
• Any controller code you write will make use of this crucial class.
• A class that exists only for the duration of page processing
• Each of processRequest(), processFormData() and processFormRequest())
takes OAPageContext as a parameter.
• OAPageContext has a reference to both the request and the root application
module
The View(JSP)
• The view formats and presents model data to the user.
• We use JDeveloper to define pages comprised of regions and
items.
• Attribute Sets
– Each region or item can inherit groups of property settings by using
attribute sets.
– A named, reusable collection of properties that can be used by any type of
UI object.
– You can override the inherited properties
• Component Reuse
– If you want to incorporate shared objects into your page, you can simply
extend them.
• Data Source Binding
– For beans with any database interaction (query, insert, update and/or
delete), you must specify a data source binding to a View Instance Name
and associated View Attribute Name.
Vital Concepts
Oracle JDeveloper 10g Components
Applications Navigator Component Palette
Code Editor
Structure window
Property Inspector
Example
– Selecting records
– Deleting records
– Inserting records
– Updating records
– Master-Detail Screen
– PPR (Partial Page Rendering)
– Deploy the example
Selecting records
1. Make sure to set the environment variable JDEV_USER_HOME
2. Make sure you are connected to an Apps instance
3. Create a new OA Workspace, StudentWS & a new OA Project,
Student
– oracle.apps.ak.student
4. Enable “OADiagnostic Run” Option to override any
corresponding profile option set for the application
5. Create 3 new BC4J packages
1. oracle.apps.ak.student.schema.server (EOs)
2. oracle.apps.ak.student.server (AMs & VOs)
3. oracle.apps.ak.student.webui (MDS pages & COs)
6. Create 2 EOs in the 1st package on
– Choose Student, Enrollment tables in schema object
– Name it StudentEO, EnrollmentEO
– Select all columns
– Leave everything to defaults until step 5.
– Check the Generate Default View Object & name it StudentVO,
EnrollmentVO
– Move StudentVO , EnrollmentVO into the 2nd package
7. Create AM in the 2nd package, name it StudentAM
– Select both VOs to create instances for them under the AM
8. Create a PG from OA Components, name it MainPG
– Set the ID property to MainRN.
– Set the Window Title property to Main Page.
– Set the Title property to Main Page for Search
– Set the AM Definition property to the AM we created
– Right click MainRN create new RN, QueryRN
– Set the Region Style to Query
– Set the Construction mode to resultsBasedSearch
– Set the includeSimple, View, AdvancedPanel to true
– Under QueryRN, create new Region using Wizard
– Choose the StudentVO1 instance
– Set Region Style to Table
– Select proper columns
– Change style to messageStyledText for all columns
9. Add the following lines to StudentEOImpl, EnrollmentEOImpl
– public void setLastUpdateLogin( oracle.jbo.domain.Number n ) {}
– public void setLastUpdatedBy( oracle.jbo.domain.Number n ) {}
– public void setLastUpdateDate( oracle.jbo.domain.Date n ) {}
– public void setCreationDate( oracle.jbo.domain.Date n ) {}
– public void setCreatedBy( oracle.jbo.domain.Number n ) {}
10. Change the StudentVO1 records to 20
11. Set the First Name Required property to true (at least 1
required)
12. Rebuild then run the MainPG.xml file
Deleting records
1. Right click StudentVO1 > New > Item
– Set item style to link
– Set prompt to Delete
– Set action type to fireAction
– Set event to deleteStudent
– Set parameters property to
• Name: pStudentId
• Value: ${oa.studentVO1.StudentId} //the record being deleted
– Right click the item > New > Image
• Set Image URL property to deleteicon_enabled.gif
2. Add a CO to trap the event raised by the link
– Right click MainRN, set New Controller in the 3rd package (webui)
– Name it MainCO
– Add code into processFormRequest method because of the submit
– EVENT_PARAM holds the name of the action has taken place
3. Add the following classes
import oracle.apps.fnd.framework.OAApplicationModule;
import java.io.Serializable;
4. Add the following code to processFormRequest
String vAction = pageContext.getParameter(EVENT_PARAM);
String vStudentId = pageContext.getParameter("pStudentId");
System.out.println("Process Form Request");