Tuesday, January 6, 2009

OA Beginner -1

1. Pages are composed of one or more regions.
2. Entity Object is a Object Oriented representation of a database table for middle tier or a logical representation of a Business Object.
Attribute validations can be performed here.
3. View Objects are based on one or more Entity Objects.
View Objects represent a database query and passing in and out parameters and results.
4. Application Modules can have one or more View Objects.


GETTING STARTED
================
Introduction>>>>>>>
OA Framework is based on J2EE MVC architecture.
Controller handles user interaction. Model handles business logic.View handles user interface.

Reuse>>>>>>>>
EO can be reused for the attribute validations across multiple application pages.
Reusable regions can be saved in MDS (MetaData Services) repository.

Setup Dev Environment (Windows) >>>>>>>>>
1. Configure JDEV_USER_HOME environment variable to \jdevhome\jdev .
2. Copy the dbc file to \dbc_files\secure directory.
3. Assign Toolbox responsibility for testing:
> OA Framework ToolBox Tutorial (responsibility key is FWK_TBX_TUTORIAL).
> OA Framework ToolBox Tutorial Labs (responsibility key is FWK_TOOLBOX_TUTORIAL_LABS).


OADeveloperMode provides extra code checking and
standards checking at runtime.
OADiagnostic enables the Diagnostics button in the global buttons at the top of the page, overriding any corresponding profile option set for the application.

To track sessions, OA Framework stores the Session ID in a session cookie.


Anatomy >>>>>>>
Page Basics:
Each UI widgets like button,table,tabs etc that renders in the page corresponds to one or more web beans in the hierarchy.
Request for a new page: request for a new page comes in --> OA framework reads the page's metadata --> create web bean hierarchy --> for each bean, OA framework calls code that we write to initialize the page --> When processing complete, OA framework hands web bean hierarchy to UIX framework to generate and send HTML to browser.
Request Form submit: OA framework recreates web bean hierarchy if necessary --> Calls any event handling code written for the page beans -->Page processing completes --> HTML is generated again and sent to browser.

[ MODEL ]
Application Module:
Each OA Framework page has a 'root' application module related to top level page region (pageLayout region). Root application module provides transaction context and database connection. If multiple pages participate in same physical/virtual transaction, they share same root application module. If page functions independently, it should have its own Application Module.

When creating a reusable UI region interacting with database, root application module may contain "nested" application modules, which inturn can nest children to any number of levels.
Root application module has access to all the data/objects held by its children and all children participate in same transaction established by the root.

Entity Objects :
BC4J EOs encapsulates business rules (validations, actions, etc) associated with a row in database table. Example, FWK_TBX_SUPPLIERS table stores supplier definitions, SupplierEO entity object implements all the business rules for inserting, updating and deleting a supplier.
EO can be based on table, views, synonyms, or snapshots.
EO can be of PL/SQL and Java types.
There is a one-to-one mapping between table and EO (between table columns and EO attributes). All EOs should include all columns in associated tables to automatically implement queries, inserts, updates and deletes. All we need to do is add the validation logic.
All validation logic for a EO should be consolidated to consistently implement business rules regardless of OA framework client.

Associated Objects :
These are complex objects by associating multiple EOs; these can be weak association (PO header, line, shipments) or strong associations (PO header owns its lines, which cannot exist outside its context).

View Objects :
BC4J VO encapsulates a database query, provides iteration over and access to result set. Each view row comprised of individual attributes.
Each VO's attribute maps either to columns in simple SQL statement (for small read only VOs), or to EO attribute (used for insert, update, delete), or to populate directly using SQL (calculated attributes or poplists not from EO).

View Links :
Just lile Associate Objects (association of EOs), View Links are VO assocaitions (view link between a PO header VO and a PO lines VO).

OADBTransaction :
It encapsulates JDBC connection / database session associated with root application module and directly owns any EO we create (VOs owned by root AM references the EO).
Access to OADBTransaction is provided by root application module.
It is also used when making callable statements to execute PL/SQL functions/procedures and session level information (user's name, id, current responsibility, etc).

[ VIEW ]
Page :
Pages comprised of Regions comprised of Items.
Items are simple widgets like button, image, etc and has no children, each item points to a style pointing to a web bean like OATableBean for example.
Regions can have items and other regions.
All pages have root level region with PageLayout style.
Sequence in which regions and items appear in JDeveloper page tree (and corresponding XML file) tells framework where to add these objects to the runtime bean hierarchy.

Attribute Sets :
A named reusable collection of properties that can be used by any UI object like regions, items, and other attribute sets.

Component Reuse :
To incorporate shared objects, you need to extend them by setting the Extends property to fully qualified shared region path (/oracle/apps/fnd/framework/toolbox/tutorial/webui/PoSummaryRN).
Shared region is not editable in referenced page.

[ CONTROLLER ]
Controller responds to user actions and directs application flow.
Controller can be associated with view at the Region level.
Controller defined how web beans behave.
Write controller to manipulate/initialize UI at runtime (that are not possible declaratively) and handle user events.

Request Handling:
When browser issues a OA.jsp request for your page -->
oracle.apps.fnd.framework.webui.OAPageBean (the main OA Framework page processing class) uses page name to determine the root AM to check-out from AM pool --> AM checks-out JDBC connection from connection pool --> transaction context for the page is established --> user session is validated --> if valid, OAPageBean evaluates request parameters to identify if this is HTTP POST or GET request.

Get Request:
Get request to server for page --> OA Framework uses declarative UI definition to build web bean hierarchy --> OAPageBean calls processRequest() on (top) PageLayout bean --> calls each web bean in hierarchy recursively --> each web bean instantiates its controller (if any) and calls processRequest() on the controller (complicated beans like OATableBean or OAPageLayoutBean perform post-controller processing by calling prepareForRendering() ) --> Each web bean calls processRequest() on its children --> OAPageBean gives web bean hierarchy to UIX to render and send to the browser.

Post Request:
OAPageBean checks if web bean hierarchy in memory (if not (resources reclaimed, user used back button, etc) recreate the hierarchy) --> OAPageBean calls processFormData() on PageLayout and then this calls processFormData() on all children beans to write form data to Model --> writing data to model invokes attributes and EO validations --> when successful, OAPageBean calls processFormRequest() on all beans in hierarchy to respond to user actions --> if no JSP forwards/redirects and no exceptions thrown in processFormRequest(), page is refreshed.

processRequest(): to construct/modify page layout, set web bean properties and do manual data initialization (like to perform an autoquery when nevigating to a page).
processFormRequest(): to respond to user actions.

The request includes:
1. any URL parameters
2. if it is a POST, any form field values plus the names and events associated with any action/control widgets selected by the user.



processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{

//A>
if (pageContext.getParameter("GoButton") != null)
{
// The user pressed the "Go" button, do something...
}

//B>
OAApplicationModule am =
(OAApplicationModule)pageContext.getRootApplicationModule();

//C>
pageContext.setForwardURL("OA.jsp?page=/oracle/apps/dem/employee/webui/EmpDetails
PG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
true, // Retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_YES, // Show breadcrumbs
OAWebBeanConstants.IGNORE_MESSAGES);

//D>
String userName = pageContext.getUserName();
}

No comments:

Post a Comment