Part 2: Creating a Data Entry Page in OAF
Introduction
This is the second and final part of the guide on creating a Data Entry Page in Oracle Application Framework (OAF). In Part 1, we created the foundational server-side objects: the database table, workspace, project, Entity Object (SupplierEntryEO), View Object (SupplierEntryVO), and Application Module (RohitDataEntryAM).
In this part, we will complete the data entry page by:
Creating the OAF Page (RohitDataEntryPG)
Adding a Main Region with
messageComponentLayoutstyleCreating Text Input Items bound to View Object attributes
Creating a Controller to handle page events
Implementing Insert and Save logic in the Application Module
Adding a Page Button Bar with a Save button
Rebuilding and running the page
Part 1 Reference: https://docodi.blogspot.com/p/10a-how-to-create-data-entry-page-in.html
Prerequisites
Before proceeding, ensure the following are complete from Part 1:
Database table XX_SUPPLIER_MASTER created
Workspace RohitDataEntryOaf created
Project RohitDataEntryOaf created
Entity Object SupplierEntryEO created
View Object SupplierEntryVO created (based on the EO)
Application Module RohitDataEntryAM created (with SupplierEntryVO attached)
Step 1: Create the OAF Page
Open the New Gallery:
Right-click on the project RohitDataEntryOaf
Select New
Select Page:
Navigate to Web Tier → JSF/Faces (or Web Tier → Oracle ADF Faces)
Select Page
Click OK
Configure the Page:
Page Name:
RohitDataEntryPGDefault Package:
rohit.oracle.apps.fnd.RohitDataEntryOaf.webui
Note: Pages are always created under the webui directory of the project, following OAF standards.
Rename the Default Region:
When the page is created, a default region (region1) is generated
In the Structure pane, select region1
In the Property Inspector, change the ID to PageLayoutRN
Attach the Application Module:
With PageLayoutRN selected, locate the AM Definition property in the Property Inspector
Set it to:
rohit.oracle.apps.fnd.RohitDataEntryOaf.server.RohitDataEntryAM
Important: Every OAF page must be associated with an Application Module. Without this association, the page cannot run.
Step 2: Create the Main Region
The Main Region will hold all the data entry fields.
Create a New Region:
Right-click on PageLayoutRN
Select New → Region
A new region (region2) is created
Configure the Region:
In the Property Inspector, change the ID to MainRN
Set Region Style to messageComponentLayout
Note: The
messageComponentLayoutregion style is commonly used for form-based data entry layouts, arranging items in a structured, label-field format.
Step 3: Create the Data Entry Items
Now we will create text input items for each column in the database table. Each item is bound to a View Object attribute.
3.1 Create Item1 (Supplier ID)
Create the Item:
Right-click on MainRN
Select New → messageTextInput
An item (item1) is created
Configure the Item:
| Property | Value |
|---|---|
| ID | SupplierId |
| View Instance | SupplierEntryVO |
| View Attribute | SupplierId |
| Prompt | Supplier No. |
3.2 Create Item2 (Supplier Name)
| Property | Value |
|---|---|
| ID | SupplierName |
| View Instance | SupplierEntryVO |
| View Attribute | SupplierName |
| Prompt | Supplier Name |
3.3 Create Item3 (Supplier Alias)
| Property | Value |
|---|---|
| ID | SupplierAlias |
| View Instance | SupplierEntryVO |
| View Attribute | SupplierAliasName |
| Prompt | Supplier Alias Name |
3.4 Create Item4 (Supplier Creation Date)
| Property | Value |
|---|---|
| ID | SupplierCreationDate |
| View Instance | SupplierEntryVO |
| View Attribute | SupplierCreationDate |
| Prompt | Supplier Creation Date |
3.5 Create Item5 (Address1)
| Property | Value |
|---|---|
| ID | Address1 |
| View Instance | SupplierEntryVO |
| View Attribute | Address1 |
| Prompt | Address1 |
3.6 Create Item6 (Address2)
| Property | Value |
|---|---|
| ID | Address2 |
| View Instance | SupplierEntryVO |
| View Attribute | Address2 |
| Prompt | Address2 |
Important: Ensure each item's View Instance is set to
SupplierEntryVOand the View Attribute matches the corresponding column in the View Object. This binding is what connects the UI field to the database column.
Step 4: Create the Controller
The Controller handles user interactions and application flow. It is where we will invoke the insert and save methods.
Create the Controller:
Right-click on PageLayoutRN
Select Set New Controller
Configure the Controller:
Controller Name:
RohitDataEntryCOPackage:
rohit.oracle.apps.fnd.RohitDataEntryOaf.webui
Note: Controllers are always created under the webui directory of the project, following OAF standards.
Step 5: Implement the Application Module Methods
Now we need to add methods to the Application Module implementation class to handle record creation and saving.
Open the Application Module Implementation:
In the Application Navigator, click on RohitDataEntryAM
In the Structure window, locate and open RohitDataEntryAMImpl.java
Add the
createrecordMethod:
public void createrecord() { OAViewObject vo = (OAViewObject)getSupplierEntryVO(); if (!vo.isPreparedForExecution()) { vo.executeQuery(); } Row row = vo.createRow(); vo.insertRow(row); row.setNewRowState(Row.STATUS_INITIALIZED); }
Explanation: This method creates a new row in the View Object and inserts it. The
STATUS_INITIALIZEDstate indicates that the row is new and ready for data entry.
Add the
saverecordMethod:
public void saverecord() { getTransaction().commit(); }
Explanation: This method commits the transaction, saving all pending changes (inserts, updates, deletes) to the database.
Step 6: Add the Page Button Bar and Save Button
Now we will add a Save button using the Page Button Bar region style.
Create the Page Button Bar Region:
Right-click on PageLayoutRN
Select New → Region
A new region (region1) is created
In the Property Inspector, set:
ID:
PageButtonsRegion Style:
pageButtonBar
Create the Save Button:
Right-click on the PageButtons region
Select New → Item
An item (item1) is created
In the Property Inspector, set:
ID:
SaveItem Style:
submitButton
Note: The
pageButtonBarregion style automatically positions buttons at the top and bottom right of the page, following Oracle's standard UI conventions.
Step 7: Write the Controller Code
Now we add the code to the Controller to handle the button click events and invoke the Application Module methods.
7.1 Code for Insert (Process Form Request)
Add the following code to invoke the create_record method when the page loads (to prepare a new row for data entry):
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean); // Invoke create_record to prepare a new row am.invokeMethod("createrecord"); }
7.2 Code for Save Button (Process Form Request)
Add the following code to handle the Save button click:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule oa = (OAApplicationModule)pageContext.getApplicationModule(webBean); if (pageContext.getParameter("Save") != null) { oa.invokeMethod("saverecord", null); } }
Explanation: When the user clicks the Save button, the
processFormRequestmethod checks if the "Save" parameter is present. If so, it invokes thesaverecordmethod on the Application Module, which commits the transaction to the database.
Note: In a complete implementation, you would combine both code blocks into a single
processFormRequestmethod, with proper conditional logic to handle different events (page load, button clicks, etc.).
Step 8: Rebuild and Run the Project
Rebuild the Project:
Right-click on the project RohitDataEntryOaf
Select Rebuild
Note: Rebuilding compiles all Java classes and ensures there are no errors before deployment.
Run the Page:
After successful compilation, right-click on the page RohitDataEntryPG
Select Run
Verify the Output:
The page should open in your default web browser
You should see the data entry form with all six fields
The Save button should appear at the top and bottom right of the page
Enter data and click Save to insert a record into the database
How the Data Entry Page Works at Runtime
The following illustrates the complete flow when a user enters data:
┌─────────────────────────────────────────────────────────────────┐
│ PAGE LOAD │
│ 1. Page loads with RohitDataEntryAM attached │
│ 2. create_record invoked → new row created in VO │
│ 3. Empty form displayed for data entry │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ USER ENTERS DATA │
│ 1. User fills in Supplier No., Supplier Name, etc. │
│ 2. Data is bound to View Object attributes │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ USER CLICKS SAVE │
│ 1. processFormRequest detects "Save" parameter │
│ 2. saverecord invoked on Application Module │
│ 3. Transaction committed → data inserted into database │
│ 4. Confirmation message displayed │
└─────────────────────────────────────────────────────────────────┘Understanding the Data Entry Flow
| Step | Action | Component | Result |
|---|---|---|---|
| 1 | Page loads | Controller | create_record invoked |
| 2 | New row created | Application Module | Empty row ready for data |
| 3 | User enters data | Page Items | Data bound to VO attributes |
| 4 | User clicks Save | Controller | saverecord invoked |
| 5 | Transaction committed | Application Module | Data inserted into database |
| 6 | Confirmation | Page | Success message displayed |
Best Practices
| Practice | Description |
|---|---|
| Use EO for DML | Always base data entry VOs on Entity Objects |
| Handle Validation | Add validation logic before commit |
| Use WHO Columns | Populate audit columns (CREATED_BY, etc.) automatically |
| Provide Feedback | Display confirmation messages after save |
| Handle Errors | Add exception handling for database errors |
| Test Edge Cases | Test with invalid data, duplicate keys, etc. |
| Follow OAF Standards | Keep AM in server and pages in webui |
Troubleshooting Common Issues
| Issue | Possible Cause | Solution |
|---|---|---|
| Save button doesn't work | Wrong parameter name | Verify pageContext.getParameter("Save") matches the button ID |
| Data not inserted | Commit not called | Verify saverecord invokes getTransaction().commit() |
| NullPointerException | VO not attached to AM | Verify SupplierEntryVO is added to RohitDataEntryAM |
| Form fields empty | View Attribute not bound | Verify each item's View Instance and View Attribute |
| Page won't run | AM not attached | Attach RohitDataEntryAM to PageLayoutRN |
| Compilation errors | Missing imports | Add necessary imports for OAViewObject, Row, etc. |
Required Import Statements
Ensure the following imports are included in your Java files:
import oracle.apps.fnd.framework.OAApplicationModule; import oracle.apps.fnd.framework.OAViewObject; import oracle.apps.fnd.framework.server.OAViewObjectImpl; import oracle.apps.fnd.framework.webui.OAPageContext; import oracle.apps.fnd.framework.webui.OAControllerImpl; import oracle.apps.fnd.framework.webui.beans.OAWebBean; import oracle.jbo.Row;
Summary
Completing the data entry page in OAF involves the following key steps:
Create the OAF Page: The user interface component
Create the Main Region: A
messageComponentLayoutregion for form fieldsCreate Text Input Items: Bind each item to a View Object attribute
Create the Controller: Handle page events and button clicks
Implement AM Methods: Add
createrecordandsaverecordmethodsAdd the Page Button Bar: Create a Save button with
submitButtonstyleWrite Controller Code: Invoke AM methods on page load and button click
Rebuild and Run: Compile and test the page
By following these steps, you have created a fully functional data entry page that allows users to enter data and save it to the database. The key components work together as follows:
Entity Object: Handles the actual DML operations against the database
View Object: Provides the data structure and binds to the UI items
Application Module: Manages the transaction and exposes methods to the controller
Controller: Handles user interactions and invokes AM methods
Page and Regions: Provide the user interface for data entry
This pattern—using an EO for DML, a VO for data access, an AM for transaction management, and a Controller for event handling—is the standard approach for building data entry pages in Oracle E-Business Suite.
References
Part 1: How to Create Data Entry Page in OAF — https://docodi.blogspot.com/p/10a-how-to-create-data-entry-page-in.html
Part 2: Creating Data Entry Page in OAF (Continued) — https://docodi.blogspot.com/p/10b-how-to-create-data-entry-page-in.html
Oracle E-Business Suite Documentation: OA Framework Developer's Guide
Oracle JDeveloper Documentation: Available in the
jdevdocfolderRelated Guides: Creating an LOV in OAF, Creating a Pop List in OAF, Assigning Default Values in OAF, OAF Region Styles
No comments:
Post a Comment