[OAF] Run Programmatic Code When a Drop-Down Value Changes in Oracle OAF


 

Working with drop-down lists (poplist beans) in Oracle Application Framework (OAF) is common in many custom pages. Often, we need to trigger some custom business logic when the user changes the value of a drop-down — like enabling/disabling another item, changing LOV values, or updating some dependent fields.

In this blog, I’ll walk you through how to capture the change event of a drop-down and execute programmatic code in the controller (CO).

 

🎯 Use Case

Let’s say we have a drop-down called Category, and based on the selected category, we want to show/hide a field named Subcategory dynamically.

 

🛠️ Steps to Implement

1. Create/Identify the Drop-Down (Poplist) Item

In your OAF page XML, ensure your drop-down item is defined and has an id, e.g., CategoryPoplist

 <messageChoice
   id="CategoryPoplist"
   prompt="Category"
   ...other attributes.../>

 

2. Set FirePartialAction Property to True

To trigger a PPR (Partial Page Rendering) event when the value changes, set:

 firePartialAction="true"

partialTriggers="CategoryPoplistAction"

 

If you don't want to add these attributes in page file, then you can set it from the controller file:

In processRequest  method write the below code which will dynamically add firePartialAction "CategoryPoplistAction" to the choice list:

 

public void processRequest(OAPageContext pageContext, OAWebBean webBean) 
    {
        super.processRequest(pageContext, webBean);
        pageContext.writeDiagnostics(this, 
                                     "Inside processRequest method", 
                                     1);

        OAMessageChoiceBean CategoryChoiceBean = 
                    (OAMessageChoiceBean)tblBean.findIndexedChildRecursive("CategoryPoplist");
                    
        FireAction firePartialAction = new FirePartialAction("CategoryPoplistAction"); 
        CategoryChoiceBean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR, firePartialAction); 
}
 
 
 
 

3. Create/Update the Controller Class

In your page’s controller (CO), override the processFormRequest method.

Here’s how you capture the value change. The below code will run only for CategoryPoplistAction

 
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) {
    super.processFormRequest(pageContext, webBean);

    if (pageContext.getParameter("event") != null 
        && pageContext.getParameter("event").equals("CategoryPoplistAction")) {
        
        String selectedCategory = pageContext.getParameter("CategoryPoplist");
        
        // Write your custom logic here
        System.out.println("Selected Category: " + selectedCategory);
        
        // Example: show/hide another field
        OAWebBean subCategoryBean = webBean.findChildRecursive("SubCategoryField");
        if (subCategoryBean != null) {
            if ("Electronics".equals(selectedCategory)) {
                subCategoryBean.setRendered(true);
            } else {
                subCategoryBean.setRendered(false);
            }
        }
    }
}
 
  
 

4. Test the Page

  • Deploy the page.

  • Navigate to it in the OAF application.

  • Change the category in the drop-down.

  • Observe that your code runs, and behavior changes accordingly (e.g., subcategory field appears or disappears).


Conclusion

That's it! You've now learned how to handle drop-down value changes in OAF and execute custom code in response. This technique is powerful for making your pages more dynamic and user-friendly.

 


Comments

All Categories

Call Fusion BIP Report2 Change Password1 Code Combinations2 Compute Instance2 CTE1 Customer1 Data Aggregation2 Database5 Date Conversion1 DB Adapter2 Decryption1 Development1 EBS4 Encryption1 ESS Jobs3 Examine1 FBDI3 Fusion APIs1 Fusion BIP7 GIT2 GL3 GL Journals1 GL_DAILY_CONVERSION_TYPES1 GL_DAILY_RATES1 ICS1 Identity Domain1 Integrations1 Java1 Journal Import1 Keys1 Legal Entity1 LookupTypeLOV1 LOV1 LOVs1 MultiPartAPIs1 Networking1 NVL2 NVL in OIC2 OCI11 OCI Billing1 OCI Compute5 OCI Cost Management1 OCI Events Service1 OCI Free Tier3 OCI Notifification Service1 OCI Security3 OIC4 OIC Mapper2 Oracle26 Oracle ADF17 Oracle APEX1 Oracle Apps59 Oracle Apps R126 Oracle ATP1 Oracle BIP8 Oracle Cloud12 Oracle Cloud Free Tier1 Oracle cloud Infrastructure9 Oracle Cloud Security2 Oracle Cloud VM1 Oracle DB4 oracle ebs5 Oracle ERP4 Oracle ERP Adapter2 Oracle ERP Cloud7 Oracle financials2 Oracle Forms1 Oracle Fusion57 Oracle Fusion BIP4 Oracle Fusion ERP17 Oracle Fusion Financials18 Oracle Integration Cloud3 Oracle OAF17 Oracle OCI14 Oracle OIC22 Oracle SOA 12c10 Oracle SQL17 Oracle VBCS1 Oracle VBS2 Oracle Visual Builder Cloud Service1 Oracle Visual Builder Studio2 Oracle Workflow Notifications1 Others10 Payables2 Payables Import1 Properties1 R121 Register BIP as ESS Job1 Reset Password1 Responsibility1 REST4 Security List1 Site Map1 SOAP2 SOAP API2 SOAP UI3 SQL16 SQL Functions3 SQL Queries14 SQL Query8 SQL Tips3 SSH1 TCA1 Value Sets1 VBCS1 Virtual Machine2 Virtual Machines1 XML1 XSLT1
Show more