This in-depth tutorial will guide you through the process of creating a dynamic action to display alert messages in Oracle Application Express (APEX). We'll cover various examples, complete with explanations, to help you understand how to use dynamic actions effectively. Follow the steps provided to implement this feature in your Oracle APEX application.
Table of Contents
- Introduction to Oracle APEX Dynamic Actions
- Prerequisites
- Creating a Dynamic Action to Show an Alert Message
- Example 1: Displaying an Alert on Button Click
- Example 2: Showing an Alert Based on Item Value
- Example 3: Displaying an Alert on Page Load
- Troubleshooting Common Issues
- Conclusion
1. Introduction to Oracle APEX Dynamic Actions
Oracle Application Express (APEX) is a powerful web application development platform that enables developers to create highly scalable and responsive web applications. One of its key features is dynamic actions, which allow developers to create client-side interactivity without writing a single line of JavaScript.
Dynamic actions provide a simple, declarative way to define how certain events or conditions trigger specific actions. One common use case for dynamic actions is to display alert messages, which can provide users with important information or feedback.
In this tutorial, we'll explore how to create dynamic actions that show alert messages in Oracle APEX.
2. Prerequisites
Before you begin, ensure you have the following:
- An Oracle APEX environment (version 18.1 or later)
- Basic knowledge of Oracle APEX components and functionality
- Familiarity with creating and editing APEX applications
3. Creating a Dynamic Action to Show an Alert Message
Example 1: Displaying an Alert on Button Click
In this example, we'll create a dynamic action that displays an alert message when a button is clicked.
Step 1: Add a Button
- Navigate to the APEX application and open the desired page in the Page Designer.
- In the
Components
pane, expand theRegions
section. - Create a
Button
component into the desired region. - Set the button properties:
Name
:SHOW_ALERT
Label
:Show Alert
Step 2: Create a Dynamic Action
- In the
Components
pane, expand theDynamic Actions
section. - Do the right click on the node to create a new dynamic action.
- Set the dynamic action properties:
Name
:DA_SHOW_ALERT
Event
:Click
Selection Type
:Button
Button
:SHOW_ALERT

Step 3: Define the Action
- In the
Components
pane, select theDA_SHOW_ALERT
dynamic action you just created. - In the
Actions
section, click the+
icon to add a new action. - Set the action properties:
Action
:Execute JavaScript Code
Code
:alert('This is an alert message.');
Now, when you click the Show Alert
button, an alert message will be displayed.

Example 2: Showing an Alert Based on Item Value
In this example, we'll create a dynamic action that displays an alert message when an item's value meets a specific condition.
Step 1: Add a Text Field Item
- In the
Components
pane, expand theItems
section. - Drag and drop a
Text Field
component into the desired region. - Set the item properties: Name
:
ITEM_VALUE`
Step 2: Create a Dynamic Action
- In the
Components
pane, expand theDynamic Actions
section. - Click the
+
icon to create a new dynamic action. - Set the dynamic action properties:
Name
:DA_ITEM_VALUE_ALERT
Event
:Change
Selection Type
:Item
Item
:ITEM_VALUE
Step 3: Define the Condition
- In the
Components
pane, select theDA_ITEM_VALUE_ALERT
dynamic action you just created. - In the
Client-side Condition
section, click the+
icon to add a new condition. - Set the condition properties:
Condition Type
:Item is NOT NULL
Item
:ITEM_VALUE
Step 4: Define the Action
- In the
Components
pane, select theDA_ITEM_VALUE_ALERT
dynamic action. - In the
Actions
section, click the+
icon to add a new action. - Set the action properties:
Action
:Execute JavaScript Code
Code
:alert('The item value is: ' + $v('ITEM_VALUE'));
Now, when the item value changes and is not null, an alert message will be displayed showing the item value.
Example 3: Displaying an Alert on Page Load
In this example, we'll create a dynamic action that displays an alert message when the page loads.
Step 1: Create a Dynamic Action
- In the
Components
pane, expand theDynamic Actions
section. - Click the
+
icon to create a new dynamic action. - Set the dynamic action properties:
Name
:DA_PAGE_LOAD_ALERT
Event
:Page Load
Step 2: Define the Action
- In the
Components
pane, select theDA_PAGE_LOAD_ALERT
dynamic action you just created. - In the
Actions
section, click the+
icon to add a new action. - Set the action properties:
Action
:Execute JavaScript Code
Code
:alert('Welcome to the page!');
Now, when the page loads, an alert message will be displayed welcoming the user to the page.
4. Troubleshooting Common Issues
If your dynamic actions aren't working as expected, consider the following troubleshooting tips:
- Verify that your dynamic action is enabled and that the event and selection type are correctly configured.
- Check the JavaScript console for any errors or warnings that might be preventing your dynamic action from executing.
- Ensure that the client-side condition (if any) is correctly configured, and test it with different values to confirm it's working as expected.
- Review the action properties, especially the JavaScript code, for any syntax errors or incorrect variable references.
5. Conclusion
In this tutorial, we covered how to create dynamic actions to show alert messages in Oracle APEX. By following the examples provided, you should now have a solid understanding of how to use dynamic actions to enhance your APEX applications' interactivity and provide valuable feedback to your users. As you become more comfortable with dynamic actions, you can explore additional events, conditions, and actions to create even more advanced functionality in your APEX applications.
Leave a comment