0% found this document useful (0 votes)
66 views74 pages

OA Framework Intro

The document discusses the Oracle Application Framework (OAF) including terminology, architecture, why MVC is used, the model, view and controller components, and provides an example of creating a simple 'Hello World' application in OAF.

Uploaded by

Asem Moha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views74 pages

OA Framework Intro

The document discusses the Oracle Application Framework (OAF) including terminology, architecture, why MVC is used, the model, view and controller components, and provides an example of creating a simple 'Hello World' application in OAF.

Uploaded by

Asem Moha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 74

OA Framework

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)

OA Controller 11i Data


Personalization vs. Extension

 Personalization – the ability to declaratively


alter (in XML) the page’s UI to meet the
business or user needs.
 Extension – the ability to programmatically
(in Java) extend the page’s functionality.
Hello World
Steps
1. Make sure to set the environment variable JDEV_USER_HOME
2. Make sure you are connected to an Apps instance
3. Enable “OADiagnostic Run” Option to override any
corresponding profile option set for the application
4. Create a new OA Workspace, HelloWorldOAWorkspace & a
new OA Project, HelloWorld
– oracle.apps.ak.hello
5. Create a new Page “HelloWorldPG” from OA components in
Web Tier
– oracle.apps.ak.hello.webui
6. If the Property Inspector is not already open, select View >
Property Inspector from the main menu
7. Click the newly created XML file in the structure window
8. Set the following properties for your page layout region(region1):
– Set the ID property to PageLayoutRN.
– Set the Window Title property to Hello World Window Title.
– Set the Title property to Hello World Page Header. This becomes the page
header for the page (it appears under the blue bar).
– Set the AM Definition property to
oracle.apps.fnd.framework.server.OAApplicationModule (you will have to
type in the value). This is a generic application module supplied by the OA
Framework.
9. Right click PageLayoutRN > New > Region
– Set the ID property to MainRN.
– Set the Region Style property to messageComponentLayout
10. Right click MainRN > New > messageTextInput
– Set the ID property to HelloName.
– 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.
11. Right click MainRN > New > messageLayout
– Set the value of the ID property to ButtonLayout
12. Right click ButtonLayout > New > Item
– Set the value of the ID property to Go.
– Set the Item Style property to submitButton.
– Set the Attribute Set property to
/oracle/apps/fnd/attributesets/Buttons/Go.
13. Right click MainRN and choose Set New Controller
– Set the package name to oracle.apps.ak.hello.webui
– Set the class name to HelloWorldMainCO
– Add the following line as the last line of the import section
oracle.apps.fnd.framework.OAException;
– Code the processFormRequest() method to match the following
• 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); } }
}
Model-View-Controller

By applying the MVC architecture,


you separate core business
model functionality from the
presentation and control logic
that uses this functionality. Such
separation allows multiple views
to share the same enterprise
data model, which makes
supporting multiple clients easier
to implement, test, and
maintain.
Why do we use MVC?
– It provides a flexible architecture for applications that is more
easily programmed and managed over the complete lifecycle.

• Model – Business logic


encapsulated in Business
BC4J Components for Java view
objects and entity objects
• View – Common UIX-based
UIX / HTML components used
OA Extension throughout Applications

• 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

– AM and VO (UI-related logic) .java and .xml files in


oracle.apps.<application shortname>. <module>.server

– Poplist- and LOV-related VO and AM .java and .xml files in


oracle.apps.<application shortname>.<module>.poplist.server
oracle.apps.<application shortname>.<module>.lov.server
Basics of the Application Module
• A BC4J application module is a container that manages and
provides access to "related" BC4J model objects.
• Each OA Framework page has a "root" application module,
which is associated with the top-level page region (the
pageLayout region).
• The root application module provides transaction context and
establishes a database connection.
• It is also possible for a root application module to contain one
or more "nested" application modules, which can themselves
nest children to any arbitrary level.
• You route your calls through the root application module
using the generic "remoteable" invokeMethod() method
Basics of the Application Module
• Encapsulates Server/Middle tier View Objects
– Container for view objects and view links
– View objects are defined by view instance names which are the
names referenced by UI framework
– Allows definition of master/detail view links
• Encapsulates Server/Middle tier controller-like logic
– Initialize and perform view object query
– Custom methods to process view objects
– Custom methods to access entities.
• OA Framework groups pages together by Root AM
– Pages with same Root AM name, and RetainAM=Y URL flag, are
handled as one AM/Transaction instance shared for both pages
– Useful for multi-page updates
– Useful for sharing expensive queries across several pages
Application Module Files

• Each AM should have:


– <YourName>AM.xml
• Declarative information about AM
– <YourName>AMImpl.java
• Add methods to be invoked from the CO
Basics of Entity Objects
– Map to a database table or other data source
– Each entity object instance represents a single row
– Contains attributes representing database columns
– Fundamental BC4J object through which all
inserts/updates/deletes interact with the database
– Central point for business logic and validation
related to a table
– Encapsulates attribute-level and entity-level
validation logic
– Can contain custom business methods
Entity Object Creation Standards
– Include all table columns in the EO.
– Base your EOs on the _ALL tables rather than on
organization-restricted views.
– Always generate accessors (setters/getters).
• Speeds up performance in attribute lookups because you
can use named accessors
• Setter/getter example
public Date getEnrollDate(){
return (Date)getAttributeInternal(ENROLLDATE);
}
public void setEnrollDate(Date value){
setAttributeInternal(ENROLLDATE, value);
}
Entity Object Automatic Features
– Validation, locking and posting order of
children
• Handled by Composite Associations
– Who Columns (Record History)
• Set automatically during EO create() or doDML()
• EO should have following attributes :
(will give an error if they don’t exist)
» CreationDate
» CreatedBy
» LastUpdateDate
» LastUpdatedBy
» LastUpdateLogin
Entity Object Files

• Each EO should have:


– <YourName>EO.xml
• Declarative information about EO
– <YourName>EOImpl.java (optional)
• Add create(), remove(), validateEntity(),
and getter/setter methods.
Basics of View Objects
– Represent a query result.
– Are used for joining, filtering, projecting, and
sorting your business data.
– Can be based on any number of entity objects.
– Can also be constructed from a SQL statement.
– View Object is designed to:
• Manage collection of data
– Main collection interface into the database data
• Provide view-like shaping of data
– Leverage SQL to join tables and corresponding EOs
Basics of View Objects
• A View Object should:
– Always delegate to other objects such as the EO
or PL/SQL for business logic
• ensures better reuse of business logic
– Contain only the attributes required for a specific
purpose
• Do not select more attributes (columns) than
required for a page/transaction UI
• View objects should be considered specific to a
particular UI and are not expected to be reused
View Object Creation Methods
• View Object can be created in one of three ways, based
on:
1. Generated SQL based on EOs
• Add ‘where clause’ at design-time, not run-time for best
performance
2. ‘Expert Mode’ custom SQL with no underlying EOs
• Read-only Data
3. ‘Expert Mode’ custom SQL manually mapped to Eos
• Unions
• Complex SQL
• SQL is encapsulated within an inner view to support
additional View Link bindings: ‘select * from (your-sql-here)’
View Objects with Entity Objects

• VO can be mapped to multiple


– Updateable EOs, though often just the primary EO
• A VO mapped to updateable EOs allows the actions on the
EO to occur through the VO.
– Reference EOs, used for additional ‘joined’ data
including description lookups
• VOs mapped to reference EOs are using those EOs just for
query purposes, generally a foreign key of some sort.
View Object Rows

– A view object controls many view rows.


– Each view row represents a row of the data that is
queried from the database.
– An entity object gets instantiated for each view row.
Creating View Objects

– When you want aliases in the query, make


sure that the attribute settings in the VO
wizard include the alias names.
– When you create or modify an "Expert
mode" VO using the View Object wizard, be
careful to make sure that the attribute
mappings match the expressions in the
query.
View Object Java Files
– Create VO Java class (VOImpl) if needed
• VOs should not contain business or validation logic, except
transient attribute logic
– Always create View Row Java class (ViewRowImpl) and
accessors (setters/getters)
View Object Files
• Each VO should have:
– <YourName>VO.xml
• Declarative information about VO
– <YourName>VOImpl.java (optional)
• Add initQuery method if needed
– <YourName>ViewRowImpl.java (required)
• Contains accessors (setters and getters) for VO
attributes
• Behind the scenes, these accessors call
corresponding methods in your EOImpl.java
Association Objects
– Defines a relationship between entity objects.
– Facilitates access to data in related entity objects
– May be based on database constraints
– May be independent of database constraints
– Consist of a source (master) and a destination (detail) entity
– Two types of Association Objects
• Composition: Strong
• Reference: Weak
– Both types can be referenced via ‘association attributes’ on Entity.

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

if (pageContext.getParameter(EVENT_PARAM) != null &&


pageContext.getParameter(EVENT_PARAM).equals("deleteStudent"))
{
System.out.println("Action in MainPG: "+vAction+vStudentId);
Serializable vDelete[] = {vAction,vStudentId};
OAApplicationModule AM =
pageContext.getApplicationModule(webBean);
Class[] paramTypes = { String.class,String.class };
AM.invokeMethod("deleteStudentMethod",vDelete,paramTypes );
}
5. Write deleteStudentMethod in the AM
– Edit StudentVO & check View Row Class for the row
implementation inside the method
– Add import oracle.jbo.Row;
– public void deleteStudentMethod( String pAction, String pStudentId )
{
System.out.println("I'm now inside deleteStudentMethod()..");
StudentVOImpl SVO = getStudentVO1();
Row row[] = SVO.getAllRowsInRange();
for (int i=0;i<row.length;i++)
{
StudentVORowImpl rowi = (StudentVORowImpl)row[i];
System.out.println("I'm now Checking which Student Id to delete.."+rowi.getStudentId());
if (rowi.getStudentId().toString().equals(pStudentId))
{
rowi.remove();
getOADBTransaction().commit();
return;
}
}
}
Inserting Records
1. Navigate to MainPG
2. Right click MainRN, New > Region of type
messageComponentLayout
– Right click this new region and create another region of type
messageLayout
– Right click this new region and create an item of type
submitButton
• Action Type: fireAction
• Event: insertStudent
• Prompt: Insert Student
3. Create new PG, ManageStudentPG
– Select StudentVO1 instance
– RegionStyle: defaultSingleColumn
4. Add the AM Definition to pageLayoutRN
5. Create the OA Controller on the top region of
ManageStudentPG and name it ManageStudentCO
– Add the following imports
import java.io.Serializable;
import oracle.apps.fnd.framework.*;
import oracle.apps.fnd.framework.webui.*;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAApplicationModule;
– Add the following code to processRequest
String vAction = pageContext.getParameter("xAction");
String vStudentId = pageContext.getParameter("xStudentId");
OAApplicationModule sam =
pageContext.getApplicationModule(webBean);
Serializable vParamList[]= {vAction,vStudentId};
if(vAction!=null && vAction.equals("insertStudent"))
{
sam.invokeMethod("insertStudentMethod", vParamList);
}
– Add the following code to processFormRequest
OAApplicationModule sam =
pageContext.getApplicationModule(webBean);
if(pageContext.getParameter("saveStudent") != null)
{
sam.invokeMethod("saveStudentToDB") ;
pageContext.setForwardURL(
"OA.jsp?page=/oracle/apps/ak/student/webui/ManageStudentPG"
,null
,OAWebBeanConstants.KEEP_MENU_CONTEXT
,null
,null
,true
,OAWebBeanConstants.ADD_BREAD_CRUMB_NO
,OAWebBeanConstants.IGNORE_MESSAGES);
}
6. Add this code to the processFormRequest of MainPG
if ((pageContext.getParameter(EVENT_PARAM) != null &&
pageContext.getParameter(EVENT_PARAM).equals("insertStudent"))
|| (pageContext.getParameter(EVENT_PARAM) != null &&
pageContext.getParameter(EVENT_PARAM).equals("updateStudent")))
{
System.out.println("Action in Main Page: "+vAction+vStudentId);
HashMap pHM = new HashMap();
pHM.put("xAction",vAction);
pHM.put("xStudentId",vStudentId);
pageContext.setForwardURL(
"OA.jsp?page=/oracle/apps/ak/student/webui/ManageStudentPG"
,null
,OAWebBeanConstants.KEEP_MENU_CONTEXT
,null
,pHM
,true
,OAWebBeanConstants.ADD_BREAD_CRUMB_NO
,OAWebBeanConstants.IGNORE_MESSAGES);
}
7. Add this code to the AM
public void insertStudentMethod(String pAction, String pStudentId){
OAViewObjectImpl svo = getStudentVO1();
if(!svo.isPreparedForExecution()){
svo.executeQuery();
}
Row srow = svo.createRow();
svo.insertRow(srow);
srow.setNewRowState(Row.STATUS_INITIALIZED);
}
public void saveStudentToDB() {
getDBTransaction().commit();
}
}

8. Navigate to ManageStudentP & Create New Region of type


messageComponentLayout
– Right click this new region and create another region of type messageLayout
– Right click this new region and create an item of type submitButton
• Action Type: fireAction
• Event: saveStudent
• Prompt: Save Student
Updating Records
1. Navigate to MainPG
2. Right click StudentVO1 > New > Item
– Set item style to link
– Set action type to fireAction
– Set event to updateStudent
– 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 updateicon_enabled.gif
3. Add the following code in the main controller MainCO.java
if ( (pageContext.getParameter(EVENT_PARAM) != null &&
pageContext.getParameter(EVENT_PARAM).equals("insertStudent")
)
|| (pageContext.getParameter(EVENT_PARAM) != null &&
pageContext.getParameter(EVENT_PARAM).equals("updateStudent)
))
4. Add these imports to the AM if not there
import oracle.apps.fnd.framework.server.*;
import oracle.apps.fnd.framework.*;
import oracle.jbo.domain.Number;
import oracle.jbo.Row;
5. Add the following code to processFormRequest in
ManageStudentCO
if ( vAction!=null && vAction.equals("updateStudent"))
{
sam.invokeMethod("updateStudentMethod", vParamList);
}
6. Add the updateStudentMethod in the AM
public void updateStudentMethod(String pAction, String pStudentId) {
try {
OAViewObjectImpl svo = getStudentVO1();
String existingWhereClause = svo.getWhereClause();
svo.setWhereClauseParams(null);
svo.setWhereClause("student_id = :1");
svo.setWhereClauseParam(0, new Number(pStudentId));
svo.executeQuery();
svo.setWhereClauseParams(null);
svo.setWhereClause(existingWhereClause);
}
catch(Exception exceptional){
throw OAException.wrapperException(exceptional);
}
}

You might also like