oracle d2k to oa framework transformation

34
Oracle D2K to OA Framework Transformation By PRajkumar on Apr 12, 2012 What is the difference between Oracle D2K form and OA Framework? It is a very innocent but important question for someone that desires to make transition from D2K to OA Framework. I hope you have already read and implemented OA Framework Getting Started. I will re-visit my own experience of implementing HelloWorld program in "OA Framework". When I implemented HelloWorld a year ago, I had no clue as to what I was doing & why I was doing those steps. I merely copied the steps from Oracle Tutorial without understanding them. Hence in this blog, I will try to explain in simple manner the meaning of OA Framework HelloWorld Program and compare the steps to D2K form [where possible]. To keep things simple, only basics will be discussed. Following key Steps were needed for HelloWorld Step 1 Create a new Workspace and a new Project as dictated by Oracle's tutorial. When defining project, you will specify a default package, which in this case was oracle.apps.ak.hello This means the following: - ak is the short name of the Application in Oracle [means fnd_applications.short_name] hello is the name of your project Step 2

Upload: zafar-imam-khan

Post on 26-Aug-2014

131 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Oracle D2K to OA Framework Transformation

Oracle D2K to OA Framework TransformationBy PRajkumar on Apr 12, 2012What is the difference between Oracle D2K form and OA Framework?It is a very innocent but important question for someone that desires to make transition from D2K to OA Framework. I hope you have already read and implemented OA Framework Getting Started. 

I will re-visit my own experience of implementing HelloWorld program in "OA Framework". When I implemented HelloWorld a year ago, I had no clue as to what I was doing & why I was doing those steps. I merely copied the steps from Oracle Tutorial without understanding them.

Hence in this blog, I will try to explain in simple manner the meaning of OA Framework HelloWorld Program and compare the steps to D2K form [where possible]. To keep things simple, only basics will be discussed.Following key Steps were needed for HelloWorld 

Step 1

Create a new Workspace and a new Project as dictated by Oracle's tutorial. When defining project, you will specify a default package, which in this case was oracle.apps.ak.hello

This means the following: -

ak is the short name of the Application in Oracle

          [means fnd_applications.short_name]

hello is the name of your project

Step 2

Next, you will create a OA Page within hello project

Think OA Page as the fmx file itself in D2K. I am saying so because this page gets attached to the form function.

Page 2: Oracle D2K to OA Framework Transformation

This page will be created within hello project, hence the package nameoracle.apps.ak.hello.webui

Note the webui, it is a convention to have page in webui, means this page represents the Web User Interface

You will assign the default AM [OAApplicationModule]. Think of AM "Connection Manager" and "Transaction State Manager" for your page

         I can't co-relate this to anything in D2k, as there is no concept of Connection Pooling and that D2k is not stateless. Reason being that as soon as you kick off a D2K Form, it connects to a single session of Oracle and sticks to that single Oracle database session. So is not the case in OAF, hence AM is needed.Step 3

You create Region within the Page.

         Region is what will store your fields. Text input fields will be of type messageTextInput. Think of Canvas in D2K. You can have nested regions. Stacked Canvas in D2K comes the closest to this component of OA FrameworkStep 4

Add a button to one of the nested regions

The itemStyle should be submitButton, in case you want the page to be submitted when this button is clicked

There is no WHEN-BUTTON-PRESSED trigger in OAF. In Framework, you will add a controller java code to handle events like Form Submit button clicks. JDeveloper generates the default code for you. Primarily two functions [should I call methods] will be created processRequest [for UI Rendering Handling] and processFormRequest

         Think of processRequest as WHEN-NEW-FORM-INSTANCE, though processRequest is very restrictive.Note

What is the difference between processRequest and processFormRequest?These two methods are available in the Default Controller class that gets created.

Page 3: Oracle D2K to OA Framework Transformation

processFormRequest

This method is commonly used to react/respond to the event that has taken place, for example click of a button. 

Some examples areif(oapagecontext.getParameter("Cancel") != null) (Do your processing for Cancellation/ Rollback)if(oapagecontext.getParameter("Submit") != null) (Do your validations and commit here)if(oapagecontext.getParameter("Update") != null) (Do your validations and commit here)In the above three examples, you could be calling oapagecontext.forwardImmediately to re-direct the page navigation to some other page if needed.processRequest

In this method, usually page rendering related code is written. Effectively, each GUI component is a bean that gets initialised during processRequest. Those who are familiar with D2K forms, something like pre-query may be written in this method.Step 5

In the controller to access the value in field "HelloName" the command is

String userContent = pageContext.getParameter("HelloName");

In D2k, we used :block.field.

In OAFramework, at submission of page, all the field values get passed into to OAPageContext object.

Use getParameter to access the field value To set the value of the field, use

OAMessageTextInputBean field

HelloName = (OAMessageTextInputBean)webBean.findChildRecursive("HelloName"); fieldHelloName.setText(pageContext,"Setting the default value" ); 

Page 4: Oracle D2K to OA Framework Transformation

Note when setting field value in controller:

Note 1. Do not set the value in processFormRequest Note 2. If the field comes from View Object, then do not use setText in controller Note 3. For control fields [that are not based on View Objects], you can use setText to assign values in processRequest methodLets take some notes to expand beyond the HelloWorld Project

Note 1

In D2K-forms we sort of created a Window, attached to Canvas, and then fields within that Canvas.

However in OA Framework, think of Page being fmx/Window, think of Region being a Canvas, and fields being within Regions. This is not a formal/accurate understanding of analogy between D2k and Framework, but is close to being logical.

Note 2

In D2k, your Forms fmb file was compiled to fmx. It was fmx file that was deployed on mid-tier. In case of OAF, your OA Page is nothing but a XML file. We call this MDS [meta data].

Whatever name you give to "Page" in OAF, an XML file of the same name gets created. This xml file must then be loaded into database by using XML Importer command.

Note 3

Apart from MDS XML file, almost everything else is merely deployed to your mid-tier. Usually this is underneath $JAVA_TOP/oracle/apps/../.. All java files will go underneath java top/oracle/apps/../.. etc. 

Note 4

When building tutorial, ignore the steps for setting "Attribute Sets". These are not mandatory. Oracle might just have developed their tutorials

Page 5: Oracle D2K to OA Framework Transformation

without including these. Think of these like Visual Attributes of D2K forms 

Note 5

Controller is where you will write any java code in OA Framework. You can create a Controller per Page or have a different Controller for each of the Regions with the same Page. 

Note 6

In the method processFormRequest of the Controller, you can access the values of the page by using notation pageContext.getParameter("<fieldname here>").

This method processFormRequest is executed when the OAF Screen/Page is submitted by click of a button. 

Note 7

Inside the controller, all the Database Related interactions for example interaction with View Objects happen via Application Module.

But why so? Because Application Module Manages the transaction state of the Application.

OAApplicationModuleImpl oaapplicationmoduleimpl =

OAApplicationModuleImpl)oapagecontext.getApplicationModule(oawebbean);

OADBTransaction oadbtransaction =

OADBTransaction)oaapplicationmoduleimpl.getDBTransaction(); 

Note 8

In D2K, we have control block or a block based on database view. Similarly, in OA Framework, if the field does not have view Object attached, then it is like a control field. Hence in HelloWorld example, field HelloName is a control field [in D2K terminology]. A view Object can either be based on a view/table, synonym or on a SQL statement. 

Page 6: Oracle D2K to OA Framework Transformation

Note 9

I wish to access the fields in multi record block that is based on view Object. Can I do this in Controller? Sure you can. To traverse through those records, do the below

         Get the reference to the View Object using (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject("VO Name Here")

         Loop through the records in View Objects using count returned from oaviewobject.getFetchedRowCount()

         For each record, fetch the value of the fields within the loop as

oracle.jbo.Row row = oaviewobject.getRowAtRangeIndex(loop index here);

(String)row.getAttribute("Column name of VO here ");Category: OracleTags: oracle_d2k_to_oa_transformation Permanent link to this entry 

Main | Enable Diagnostics... »Comments:

OAF Hello World TutorialBy PRajkumar on Apr 18, 2012

1. Create a New OA Workspace and Empty OA Project

File> New > General> Workspace Configured for Oracle Applications

Page 7: Oracle D2K to OA Framework Transformation

 

 

Page 8: Oracle D2K to OA Framework Transformation

 

Page 9: Oracle D2K to OA Framework Transformation

 

 

Page 10: Oracle D2K to OA Framework Transformation

 

Page 11: Oracle D2K to OA Framework Transformation

 

2. Set Run Options in OA Project Setting

Select Your Project in the Navigator and choose Project Properties

Select Oracle Applications > Run Options

Select OADeveloperMode and OADiagnostic, and move them to selected Options List

 

3. Create Application Module AM

Page 12: Oracle D2K to OA Framework Transformation

 

Page 13: Oracle D2K to OA Framework Transformation

 

Page 14: Oracle D2K to OA Framework Transformation

 

Page 15: Oracle D2K to OA Framework Transformation

 

 

4. Create a OA components Page

Page 16: Oracle D2K to OA Framework Transformation

 

Page 17: Oracle D2K to OA Framework Transformation

 

 

5. Modify the Page Layout (Top-level) Region

Page 18: Oracle D2K to OA Framework Transformation

 

 

Attribute Property

ID PageLayoutRN

Region Style pageLayout

Form Property True

Auto Footer True

Window Title Hello World Window Title

Title Hello World Page Header

Page 19: Oracle D2K to OA Framework Transformation

AM Definition prajkumar.oracle.apps.ak.hello.server.HelloAM

 

 

 

Page 20: Oracle D2K to OA Framework Transformation

6. Create the Second Region (Main Content Region)

 

 Attribute Property

ID MainRN

Region Style messageComponentLayout

 

 

7. Create the first Item (Empty Field)

MainRN > New > messageTextInput

Page 21: Oracle D2K to OA Framework Transformation

 

 Attribute Property

ID HelloName

Style Property messageTextInput

Prompt Name

Length 20

Maximum Length 50

 

 

Page 22: Oracle D2K to OA Framework Transformation

 

 

8. Create a container Region for Go-Button

MainRN > messageLayout

Page 23: Oracle D2K to OA Framework Transformation

 

 

 Attribute Property

Region ButtonLayout

 

 

Page 24: Oracle D2K to OA Framework Transformation

 

9. Create a Second Item (Go Button)

Select ButtonLayout > New > Item

Page 25: Oracle D2K to OA Framework Transformation

 

 Attribute Property

ID Go

Item Style submitButton

Attribute /oracle/apps/fnd/attributesets/Buttons/Go

 

 

Page 26: Oracle D2K to OA Framework Transformation

 

Page 27: Oracle D2K to OA Framework Transformation

 

 

10. Save Your Work

 

11. Run Your Page Your Page UI is ready

Page 28: Oracle D2K to OA Framework Transformation

 

12. Add a Controller

MainRN > Set New Controller

 

 

Page 29: Oracle D2K to OA Framework Transformation

 

 

13. Edit Your Controller

Add Following OA Exception as a last line in import section

import oracle.apps.fnd.framework.OAException;

Add Following Code in processFormRequest

     public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

     {

            super.processFormRequest(pageContext, webBean);

             if (pageContext.getParameter("Go") != null)

Page 30: Oracle D2K to OA Framework Transformation

            {

                     String userContent = pageContext.getParameter("HelloName");

                     String message = "Hello, " + userContent + "!";

                     throw new OAException(message, OAException.INFORMATION);

      }

     }

 

 

Page 31: Oracle D2K to OA Framework Transformation

 

14. Build Your Controller

Page 32: Oracle D2K to OA Framework Transformation

 

 

15. Test Your Work Your Hello World Page is Ready

 

 

Page 33: Oracle D2K to OA Framework Transformation

 

 

 

 Category: OracleTags: oaf_hello_world_tutorial