You are on page 1of 25

OA Framework Event Flows

Copyright © Oracle Corporation, 2002. All rights reserved.


Agenda

• Overview
• Initial Setup Flow
• Controller Event Flows
• Request Flow (GET)
• Submit Flow (POST)

1-2 Copyright © Oracle Corporation, 2002. All rights reserved.


Overview

Understanding the common OA Framework event


flows is essential to aid:
• Coding
– Logic execution order
• Debugging
– Breakpoint placement

1-3 Copyright © Oracle Corporation, 2002. All rights reserved.


Initial Setup Flow

Request
JSP OAPageBean OAPageContext
from Browser

When a user makes a request from the browser:


• Request is received by the JSP
• JSP invokes OAPageBean
• OAPageBean creates OAPageContext
– Provides access to the state of the page
– Provides hooks into OA Framework services

1-4 Copyright © Oracle Corporation, 2002. All rights reserved.


Controller Event Flows in OA Framework

• Two main OAController event flows


– “Initialize page” used for HTTP GET (URL)
- primarily processRequest

– “Submit action” used for HTTP POST (Form Submit)


- processFormData and processFormRequest
• Form submits (such as button presses) are
directed back to the original OAController

1-5 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow – Overview

1. Get session info


2. Fetch metadata
3. Get Root AM and validate user session
4. Instantiate BC4J and UIX objects
5. Walk UIX tree and call processRequest on
controllers
6. Perform post processing for complex beans
7. UIX renders page

1-6 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(1) Get info and validate user

Get ICX session


cookie
 URL provides:
– Database (DBC) information
– Page name
– Other parameters
(2)

1-7 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(2) Fetch Metadata
Metadata NO
in cache?

YES MDS
Fetch metadata Repository

Apply  Metadata fetched through separate


personalizations static connection
 At customer sites metadata will be
in the database
(3)
 In JDeveloper you can work against
XML files, the repository, or both

1-8 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(3) Get Root AM, Validate Session

Get  AM associated with page


root BC4J AM
is root AM

Validate session  Root AM holds the


on root AM database connection

Validate Function
associated w/ page

(4)

1-9 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(4) Instantiate BC4J and UIX Classes

Build OA bean Instantiate assoc. Place bean bound


hierarchy from BC4J objects values (if any)
metadata

Cache OA bean
hierarchy on root AM (5)

 At runtime, UI regions and items map to Web beans


 OA beans are extensions of UIX beans

1-10 Copyright © Oracle Corporation, 2002. All rights reserved.


Example Bean Hierarchy Structure

Request
JSP OAPage Bean OAPageContext
from Browser

PageLayout Bean

Header Bean

Text Bean Text Bean

1-11 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(5) processRequest

Walk bean hierarchy


- Instantiate controller classes
- Call processRequest() on controllers
(6)

 In processRequest developers can query data (using


vo.executeQuery) and set bean properties
programmatically

1-12 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(6) Post-Processing

• Perform post-processing on complex beans


– OAPageLayoutBean and OATableBean for
example
– Post-processing can also be initiated from
processRequest by calling prepareForRendering
method
• Places data binding objects on rendering
context

1-13 Copyright © Oracle Corporation, 2002. All rights reserved.


GET Event Flow
(7) UIX Renders the Page

• UIX generates page by calling UIX render


method recursively
• UIX uses DataObjects and BoundValue
interfaces to fill in values
– DataObjectList – View Object
– DataObject – View Row

1-14 Copyright © Oracle Corporation, 2002. All rights reserved.


Structure of a Web Bean
Dictionary

BaseMutableUINode Key Value


OAStyledTextBean “text” “Hello World”
_indexedChildren “style” “OraTipText”

_namedChildren

_attributes

Hello World
getAttributeValue
setAttributeValue

1-15 Copyright © Oracle Corporation, 2002. All rights reserved.


Data Binding
WebBean

_attributes Dictionary OADataBound


Value
viewUsage VO1

viewAttr Attr1
RenderingContext
getAttributeValue text
(context, “text”)
VO1

UIX

1-16 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow – Overview

1. User does something to cause a form submit


2. UIX performs client-side validation on the browser
3. Browser sends the POST request
4. Validate user
5. Retrieve AM and bean hierarchy if saved
6. Walk UIX tree and apply form data to data objects
in processFormData
7. Walk UIX tree and call processFormRequest on
controllers
8. If no redirect then refresh the page

1-17 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(1 - 3) Submit, Client-Side Validation

• User does something to cause a form submit


(such as button press or PPR event)
• UIX performs onSubmit Javascript client-side
validation on the browser
• Browser sends the POST request only if the client-
side validation succeeds

1-18 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(4 & 5) Validate User and Retrieve State

• Validate the user as in GET


• Retrieve AM and cached copy of bean hierarchy.
If the bean hierarchy is not found:
– Validate session and function as in GET
– Go through processRequest logic again to
recreate the bean hierarchy
Your code must be prepared to expect this!

1-19 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(6) Apply Form Data

First pass through the bean hierarchy:


• Apply form data back to underlying objects in
processFormData
– If a primary key is defined for the object, validate
that the data is being applied to the correct object
– Throw state error if data is out of synch
• Within processFormData, OA Framework calls
setAttribute on the current row of the
underlying VO for each bean.
– Executes any attribute-level validation you've
written for the view object row (ViewRowImpl)

1-20 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(6) More of processFormData

Attribute-level validation:
• Within view row setAttribute, the view row
automatically calls the corresponding
set<AttributeName> in the underlying entity
object.
– This executes any associated attribute-level
validation in the entity object.

1-21 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(6) More of processFormData

Row-level validation:
• Once all the attribute values have been set, the OA
Framework calls the VO validate for each row it
modified to execute any associated row-level
validation.
– Within validate, the view row
calls validateEntity for the underlying EO,
which executes any entity-level validation.
Debugging Tip: Any declarative BC4J validation
(such as Update While New specified in BC4J
wizards) fires after validation in your Impl.java
files.

1-22 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(6) More of processFormData

• OA Framework automatically displays error


messages for any exceptions thrown by the model
layer during processFormData.
– Bad attribute values are maintained in the
OAAttrValException object
– If there are errors, code does not proceed to the
next phase of calling processFormRequest
Debugging Tip: If your code never gets to a
debugger breakpoint in processFormRequest, it
probably had an error in processFormData.

1-23 Copyright © Oracle Corporation, 2002. All rights reserved.


POST Event Flow
(7) processFormRequest
• Walk UIX tree and call processFormRequest on
controllers (second pass through the bean
hierarchy)
– Developers can respond to events or redirect to
another page
• If no redirect (or if errors are thrown) redraw the
page

1-24 Copyright © Oracle Corporation, 2002. All rights reserved.


Summary

You should now be able to understand the following:


• Initial Setup Flow
• Controller Event Flows
• Request Flow (GET)
• Submit Flow (POST)
• Much of the event flow happens automatically
through OA Framework or BC4J.
• Understanding the flow helps greatly with coding
and debugging.

1-25 Copyright © Oracle Corporation, 2002. All rights reserved.

You might also like