19. Updates Records in OAF Page

 

How to Create an Update Page in Oracle Application Framework (OAF)

Introduction

An Update Page in Oracle Application Framework (OAF) allows users to modify existing records in the database. Unlike a data entry page (which inserts new records), an update page retrieves existing data, displays it for editing, and saves the changes back to the database.

This guide builds on the Search Page created in a previous tutorial. The typical flow is:

  1. Search Page: User searches for records and views results in a table

  2. Update Page: User clicks an update icon to open a page pre-populated with the selected record's data

  3. Modify and Save: User edits the fields and clicks Update to save changes

Prerequisite Reading: Creating a Search Page in OAF — http://rpforacle.blogspot.com/2013/03/creating-search-page-in-oaf.html


Prerequisites

Before proceeding, ensure the following are complete:

  • Workspace and project RohitSearchPage created

  • Search Page (RohitSearchPagePG) created and functional

  • View Object SupplierVO created

  • Application Module RohitSearchPageAM created with SupplierVO attached

  • Controller RohitSearchPageCO created for the search page

Important: The update page uses the same Application Module as the search page. This allows the update page to access the row currently selected in the search results.


Step 1: Create the Update Page

  1. Open the New Gallery:

    • Right-click on the project RohitSearchPage

    • Select New

  2. Select Page:

    • Navigate to Web Tier → JSF/Faces (or Web Tier → Oracle ADF Faces)

    • Select Page

    • Click OK

  3. Configure the Page:

    • Page Name: RohitUpdatePG

    • Default Package: rohit.oracle.apps.fnd.RohitSearchPage.webui

Note: Pages are always created under the webui directory of the project, following OAF standards.

  1. Complete the Page Creation:

    • Click OK to create the page


Step 2: Configure the PageLayoutRN Region

  1. Rename the Default Region:

    • In the Structure pane, click on region1

    • In the Property Inspector, change the ID to PageLayoutRN

  2. Attach the Application Module:

    • With PageLayoutRN selected, locate the AM Definition property

    • Set it to:

      text
      rohit.oracle.apps.fnd.RohitSearchPage.server.RohitSearchPageAM
  3. Set Page Properties:

    • Window Title: Rohit Tutorial

    • Title: Update Page

Important: The update page uses the same Application Module as the search page. This is essential because the AM holds the currently selected row from the search results. When the update page opens, it can access that row and display its data.


Step 3: Create the Main Region

  1. Create a New Region:

    • Right-click on PageLayoutRN

    • Select New → Region

    • A new region (region1) is created

  2. Configure the Region:

    • In the Property Inspector, set:

      • ID: MainRN

      • Region Style: messageComponentLayout

Note: The messageComponentLayout region style is commonly used for form-based layouts, arranging items in a structured, label-field format.


Step 4: Create the Data Entry Items

Now we create text input items bound to the View Object attributes for editing.

  1. Create Item1:

    • Right-click on MainRN

    • Select New → messageTextInput

    • An item (item1) is created

  2. Configure Item1:

PropertyValue
View InstanceSupplierVO
Item StylemessageTextInput
View AttributeSupplierId
PromptSupplier No.
  1. Create Item2:

    • Repeat the process to create a second item (item2)

  2. Configure Item2:

PropertyValue
View InstanceSupplierVO
Item StylemessageTextInput
View AttributeSupplierName
PromptSupplier Name

Note: These items are bound to the SupplierVO attributes. When the update page opens with a selected row, these fields are automatically populated with the current values, ready for editing.


Step 5: Create the Button Bar Region

  1. Create a New Region:

    • Right-click on PageLayoutRN

    • Select New → Region

    • A new region (region1) is created

  2. Configure the Region:

    • In the Property Inspector, set:

      • ID: ButtonPage

      • Region Style: pageButtonBar

Note: The pageButtonBar region style automatically positions buttons at the top and bottom right of the page, following Oracle's standard UI conventions.


Step 6: Create the Update and Cancel Buttons

  1. Create the Update Button:

    • Right-click on ButtonPage

    • Select New → Item

    • An item (item3) is created

  2. Configure the Update Button:

PropertyValue
Item StylesubmitButton
PromptUpdate
  1. Create the Cancel Button:

    • Repeat the process to create a second item (item4)

  2. Configure the Cancel Button:

PropertyValue
Item StylesubmitButton
PromptCancel

Step 7: Create the Update Page Controller

  1. Create the Controller:

    • Under the page RohitUpdatePG, right-click on PageLayoutRN

    • Select Set New Controller

  2. Configure the Controller:

    • Controller Name: RohitUpdatePageCO

    • Package: rohit.oracle.apps.fnd.RohitSearchPage.webui

Note: Controllers are always created under the webui directory of the project, following OAF standards.


Step 8: Add an Update Icon to the Search Page Results

Now we need to add an update icon to the search page results table so users can click it to open the update page.

  1. Open the Search Page:

    • In the Application Navigator, open RohitSearchPagePG

  2. Create a New Item in the Results Table:

    • In the Structure pane, right-click on ResultsTable (under MainRN)

    • Select New → Item

    • An item (item1) is created under ResultsTable

  3. Configure the Update Icon:

PropertyValue
IDUpdate
Item Styleimage
PromptUpdate
Image URIupdateicon_enabled.gif
Action TypefireAction
Eventupdate_action

Explanation: This creates a clickable update icon in each row of the search results. When clicked, it fires the update_action event, which we will handle in the controller to navigate to the update page.


Step 9: Write the Controller Code

9.1 Code in RohitSearchPageCO (Process Form Request)

Add the following code to handle the update_action event and navigate to the update page:

java
if ("update_action".equals(pageContext.getParameter(EVENT_PARAM)))
{
    pageContext.setForwardURL(
        "OA.jsp?page=/rohit/oracle/apps/fnd/RohitSearchPage/webui/RohitUpdatePG",
        null,
        OAWebBeanConstants.KEEP_MENU_CONTEXT,
        null,
        null,
        true,
        OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
        OAWebBeanConstants.IGNORE_MESSAGES);
}

Explanation: When the user clicks the update icon, this code forwards the user to the update page (RohitUpdatePG). The KEEP_MENU_CONTEXT constant ensures the menu context is preserved, and ADD_BREAD_CRUMB_NO prevents adding a breadcrumb.

9.2 Code in RohitUpdatePageCO (Process Form Request)

Add the following code to handle the Update and Cancel button clicks:

java
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);

if (pageContext.getParameter("item3") != null)
{
    am.invokeMethod("apply");
}

if (pageContext.getParameter("item4") != null)
{
    am.invokeMethod("cancel");
}

Explanation:

  • item3 (Update): When clicked, invokes the apply method on the Application Module, which commits the changes to the database

  • item4 (Cancel): When clicked, invokes the cancel method, which discards the changes and returns to the search page

Note: In a complete implementation, you would also need to add the apply and cancel methods to the Application Module implementation class (RohitSearchPageAMImpl.java).


Step 10: Rebuild and Run the Project

  1. Rebuild the Project:

    • Right-click on the project RohitSearchPage

    • Select Rebuild

Note: Rebuilding compiles all Java classes and ensures there are no errors before deployment.

  1. Run the Search Page:

    • After successful compilation, right-click on RohitSearchPagePG

    • Select Run

  2. Test the Update Flow:

    • The search page opens in your browser

    • Enter search criteria and click Go to retrieve records

    • Click the Update icon next to a record

    • The update page opens with the record's data pre-populated

    • Modify the fields and click Update to save changes

    • Or click Cancel to discard changes and return to the search page


How the Update Page Works at Runtime

The following illustrates the complete flow:

text
┌─────────────────────────────────────────────────────────────────┐
│                     SEARCH PAGE                                 │
│  1. User enters search criteria and clicks Go                   │
│  2. Results displayed in table with Update icons                │
│  3. User clicks Update icon on a specific row                   │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                  CONTROLLER (RohitSearchPageCO)                 │
│  1. Detects "update_action" event                               │
│  2. Forwards to RohitUpdatePG                                   │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                     UPDATE PAGE                                 │
│  1. Same AM (RohitSearchPageAM) provides the selected row       │
│  2. Fields populated with current values                        │
│  3. User modifies data                                          │
│  4. User clicks Update or Cancel                                │
└─────────────────────────────────────────────────────────────────┘
                              │
              ┌───────────────┴───────────────┐
              ▼                               ▼
┌─────────────────────────┐     ┌─────────────────────────┐
│      UPDATE CLICKED     │     │     CANCEL CLICKED      │
│  apply() invoked        │     │  cancel() invoked       │
│  Changes committed      │     │  Changes discarded      │
│  to database            │     │  Return to search page  │
└─────────────────────────┘     └─────────────────────────┘

Understanding the Update Page Architecture

ComponentRoleRelationship
Search PageDisplays results with update iconsSource of the selected row
Update PageDisplays selected row for editingUses the same AM as search page
Application ModuleHolds the selected row and manages transactionShared between both pages
Search Page ControllerHandles update icon click and navigationForwards to update page
Update Page ControllerHandles Update and Cancel button clicksInvokes AM methods

Why Share the Application Module?

The key architectural decision in this design is that both the search page and the update page use the same Application Module. This is intentional and important because:

  • The search page's AM holds the current row (the record the user selected)

  • When the update page opens, it accesses the same AM and therefore the same row

  • The update page's fields are automatically populated with the selected row's data

  • When the user clicks Update, the changes are applied to the same row in the AM and committed

Alternative Approach: In some implementations, a separate AM is used for the update page, and the row is passed via parameters or session storage. However, sharing the AM is simpler and more common for this pattern.


Best Practices

PracticeDescription
Share the AMUse the same AM for search and update pages
Use Image IconsUse standard Oracle icons (e.g., updateicon_enabled.gif)
Provide CancelAlways provide a Cancel button to discard changes
Handle ValidationAdd validation before applying changes
Confirm UpdatesDisplay a confirmation message after successful update
Handle ErrorsAdd exception handling for database errors
Test Edge CasesTest with no row selected, invalid data, etc.

Troubleshooting Common Issues

IssuePossible CauseSolution
Update page shows empty fieldsAM not sharedVerify both pages use RohitSearchPageAM
Update icon doesn't workWrong event nameVerify the event matches in item and controller
Changes not savedapply method not implementedAdd the apply method to AM implementation
Navigation failsWrong page pathVerify the path in setForwardURL
Cancel doesn't workcancel method not implementedAdd the cancel method to AM implementation
Compilation errorsMissing importsAdd imports for OAWebBeanConstants, etc.

Required Import Statements

java
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

Summary

Creating an update page in OAF involves the following key steps:

  1. Create the Update Page: A new page with its own PageLayoutRN

  2. Share the Application Module: Attach the same AM used by the search page

  3. Create the Main Region: A messageComponentLayout region for form fields

  4. Create Data Entry Items: Bind items to View Object attributes

  5. Create the Button Bar: Add Update and Cancel buttons

  6. Create the Update Controller: Handle button clicks

  7. Add Update Icon to Search Page: Create an image item with fireAction

  8. Write Navigation Code: Forward to the update page on icon click

  9. Write Update/Cancel Code: Invoke apply and cancel methods

  10. Rebuild and Test: Compile and verify the complete flow

The key insight of this pattern is that the Application Module is shared between the search page and the update page. This allows the update page to automatically access the row selected on the search page, pre-populating the form fields with current values. When the user saves, the changes are applied to that same row and committed to the database.

This search-then-update pattern is one of the most common and important design patterns in Oracle E-Business Suite development, used extensively throughout standard Oracle Applications and custom extensions.


References

  • Prerequisite: Creating a Search Page in OAF — http://rpforacle.blogspot.com/2013/03/creating-search-page-in-oaf.html

  • Oracle E-Business Suite Documentation: OA Framework Developer's Guide

  • Oracle JDeveloper Documentation: Available in the jdevdoc folder

  • Related Guides: Creating a Data Entry Page in OAF, Creating an LOV in OAF, Creating a Pop List in OAF, OAF Region Styles

No comments:

Post a Comment