Skip to main content

Command Palette

Search for a command to run...

Improving User Experience (UX) in Oracle APEX

From Functional to Fantastic: Tricks with JavaScript, Dynamic Actions, and Page Items to create modern applications.

Updated
6 min read
Improving User Experience (UX) in Oracle APEX

🇪🇸 Leer en Español

Introduction: From Functional to Fantastic

You've mastered the basics (Best Practices) and bulletproofed your app (Security). Now, it's time to go for the WOW factor: the User Experience (UX).

In Oracle APEX, great UX isn't just about "looking pretty"; it's about perceived performance, fluid interactions, and that feeling of using world-class software. In this APEX Insights post, we're going to transform functional apps into exceptional experiences by mastering Dynamic Actions and the JavaScript API.

1. Mastering Dynamic Actions

Dynamic Actions (DAs) are the declarative bridge between the Frontend (JavaScript) and the Backend (PL/SQL). Using them correctly is key to your page's reactivity.

Trick 1: When to Use DAs vs. Pure JavaScript

ScenarioRecommendationReason
Simple Interactions (Show/Hide, Enable/Disable, Alert)Dynamic Actions (Declarative)Less code, faster to maintain. APEX handles event logic.
Complex Business Logic (Calculations with 5+ variables, advanced validations, array manipulation)PL/SQL (via DA AJAX Call)Logic should reside in the database or PL/SQL, not the client, for security and scalability.
DOM Manipulation, External Libraries, or Custom EventsPure JavaScript (via DA Execute JavaScript Code)APEX exposes the JavaScript engine; use it for specific Frontend tasks.

Trick 2: Optimize Fire on Initialization

The Fire on Initialization property of a DA can cause performance issues if overused.

  • Avoid: Using Fire on Initialization for logic that will only affect items when they are visible. Load it only when necessary.
  • Prefer: If you need to initialize many items, group the logic into a single JavaScript function and execute that function with a DA triggered by the Page Load event. A single call is more efficient than multiple individual calls.

2. Improving Perceived Performance with Visual Feedback

Perceived performance is how fast the user feels the application responds. It is vital to use visual feedback while the server is working.

Trick 3: Always Use a Spinner for AJAX Calls

When you execute a server process (DA AJAX Call or apex.server.process), the user must know that something is happening.

Poor PracticeRecommended Practice
The button or page simply freezes while waiting for the server response.Show a loading spinner that auto-hides when the call finishes.

Practical Example of Spinner in JavaScript:

This code shows a spinner overlaid on a region while the AJAX call to the server is executing.

// AJAX Execution (e.g., in a DA "Execute JavaScript Code")

// 1. Show the Spinner in the main region (or a specific selector)
// apex.util.showSpinner is used to overlay a spinner on the selector
const selectorRegion = "#region_id_my_region";
apex.util.showSpinner($(selectorRegion)); 

// 2. Call the server process (e.g., using apex.server.process)
apex.server.process(
    "MY_AJAX_PROCESS", 
    { x01: $v('P1_ITEM_ID') },
    {
        success: function(pData) {
            // Success logic
            console.log("Data updated");
        },
        complete: function() {
            // 3. HIDE the spinner always, in case of success or error
            $(selectorRegion).remove('.u-Processing');
        }
    }
);

Trick 4: Instant Success Messages

After a DML process (Insert, Update, Delete) or an important calculation, notify the user clearly and immediately.

  • Use apex.message.showPageSuccess('Record saved successfully!'); for positive messages.
  • Use apex.message.showErrors() for elegant and non-intrusive error handling (avoid the annoying alert()).

3. Advanced Interactions with the APEX JavaScript API

The APEX JavaScript API (available under the apex namespace) is your most powerful tool for working with page elements securely and in a standardized way.

Trick 5: Forget DOM JavaScript (document.getElementById)

⚠️ WARNING Never directly manipulate the DOM to get or set page item values (document.getElementById). If you change the internal ID or item type in the future, your code will break silently.

The APEX Method: Always use the apex.item() API to interact with page items. This API handles data types, internal bindings, and ensures you interact with the correct item regardless of its type (Radio Group, Select List, Input, etc.).

TaskPoor PracticeRecommended Practice (APEX API)
Get Valuedocument.getElementById('P1_ITEM').value$v('P1_ITEM') or apex.item('P1_ITEM').getValue()
Set Valuedocument.getElementById('P1_ITEM').value = 'X'$s('P1_ITEM', 'X') or apex.item('P1_ITEM').setValue('X')
Disable$('#P1_ITEM').prop('disabled', true)apex.item('P1_ITEM').disable()

Trick 6: Use API Shortcuts

Use shortcuts ($v, $s) to get and set values in JavaScript for cleaner and more concise code.

Practical Example: Client-Side Calculation

This code executes a simple calculation in the browser, avoiding a trip to the server.

// Triggered on Change event of item P1_QUANTITY

// Get values securely (Shortcut $v)
const quantity = $v('P1_QUANTITY');
const price = $v('P1_PRICE');

// Convert to number before operating (Javascript)
const total = parseFloat(quantity) * parseFloat(price);

// Set value securely (Shortcut $s)
$s('P1_TOTAL', total.toFixed(2));

4. Strategy with Page Items: Reduce the Round-Trip

The round-trip (trip to the server) is the biggest enemy of UX in APEX. If you can avoid reloading or calling the server, do it.

Trick 7: Client-Side Validations

Whenever possible, perform simple validations (e.g., required field, email format, length) on the client side (JavaScript or Dynamic Actions) before submitting the page or calling an AJAX process. This saves the user from waiting for a server response for a trivial error.

Trick 8: Clear Items with Clear Cache Intelligently

When a button on your page clears all items on it (Clear Cache: P1), APEX must make a trip to the server to reset the session state.

  • UX Alternative: If you only need to clear a few items, do it with a Dynamic Action that executes apex.item('P1_ITEM').setValue(null) on the client. This is instant and much faster than a full round-trip.

Conclusion

The difference between a "good" and an excellent APEX application lies in the details. By embracing the declarative power of Dynamic Actions and using the JavaScript API (apex.item, apex.server) with discipline, you're not just building faster—you're delivering a product your users will love to use.

Stop building static screens. Start building experiences.

References

  1. APEX JavaScript API Guide: The official reference for all namespaces (apex.item, apex.server, apex.message, etc.).
  2. Dynamic Actions Documentation: Deep dive into available events and actions.
  3. Oracle LiveLabs - APEX Development: Learning modules on modern JavaScript usage in APEX.

Which of these tips do you find most critical for improving your app's perceived speed? Share your opinion or your best UX trick in the comments.

Don't miss the next Insight! We will explore how to Optimize Performance in APEX in depth, focusing on strategies to reduce database load and accelerate response time. Subscribe to get notified.


🚀 Need an APEX Expert?

I help companies facilitate professional Oracle APEX development and DevOps. If you want to build better applications or automate your pipeline, let's talk.

☕ Schedule a Coffee|💼 Connect on LinkedIn

💖 Support My Work

If you found this article helpful, consider supporting me!

GitHub Sponsors | Buy Me a Coffee

Your support helps me keep creating open-source demos and content for the Oracle APEX community. 🚀