Introduction: –
In Oracle APEX applications, success messages play a vital role in providing feedback to users about the successful completion of actions or processes. However, leaving these messages displayed indefinitely can clutter the user interface and detract from a seamless user experience. To enhance usability, we can configure success messages to automatically disappear based on specific conditions.
The following technologies has been used to achieve the same.
- Oracle APEX
- Java script
Why we need to do: –
Cluttered Interface: Persistent success messages can occupy valuable screen space, disrupting the flow of the application’s design and user experience.
User Distraction: Users might be distracted by outdated success messages, especially when performing multiple actions in a sequence.
Inefficient Communication: Without a mechanism to hide success messages, users might misinterpret old messages as feedback for new actions.
Enhanced User Experience: Auto-disappearing messages ensure the interface remains clean and intuitive, focusing the user’s attention on the current task or important information.
How do we solve: –
Step:1 – Create a Global Page Item
Create a global page item named P0_PAGE_ID and set it as Hidden.
This page item will be used to store the page number on page load for every page.
Step:2 – Create an Application Process
Navigate to Shared Components and create an Application Process named Get_Page_ID.
Set the Processing Point to On-Load: Before Header.
Use the following PL/SQL code in the process:
SELECT PAGE_ID
INTO :P0_PAGE_ID
FROM APEX_APPLICATION_PAGES
WHERE APPLICATION_ID = 268642
AND PAGE_ID = :APP_PAGE_ID;
This process ensures that on every page load, the page number is stored in the P0_PAGE_ID page item
Step:3 – Create a Dynamic Action on the Global Page
Go to the Global Page and create a Dynamic Action with the event set to Page Load.
Add a JavaScript True Action and paste the following code:
var validPageIds = [“1”, “3”];
var currentPageId = apex.item(‘P0_PAGE_ID’).getValue();
if (validPageIds.includes(currentPageId)) {
apex.message.setDismissPreferences({
dismissPageSuccess: true,
dismissPageSuccessDuration: 10000 // Success message stays for 10 seconds
});
} else {
apex.message.setDismissPreferences({
dismissPageSuccess: true,
dismissPageSuccessDuration: 2000 // Success message stays for 2 seconds
});
}
This setup ensures that the page number is saved to the P0_PAGE_ID page item during every page load, and success messages will have different display duration based on the page ID
Conclusion: –
Implementing auto-disappearing success messages in Oracle APEX is a simple yet effective way to enhance the user experience. By dynamically hiding these messages based on specific conditions, we can maintain a clean and intuitive interface, reduce distractions, and ensure efficient communication with users.