Search This Blog

Tuesday, June 24, 2025

 

How Do I manage The Error Message Display Location

Error Message Display Location in Oracle APEX

The error message display location identifies where a validation error message displays. Validation error messages can display on an error page or inline within the existing page. Inline error messages can display in a notification area (defined as part of the page template) or within the field label.

To create a hard error that stops processes, including any remaining validations, you must display the error on an error page.

In Oracle APEX, error messages guide users when something goes wrong, such as missing required fields, incorrect data formats, or system errors. APEX provides various options to control where error messages appear, improving user experience and making it easier for users to correct mistakes.

This tutorial explains the different error message display locations in APEX and how to configure them for different scenarios.


Types of Error Messages in APEX

Error messages in APEX can be triggered by:

  • Validations – Enforce required fields, check data formats, or validate data against business rules.

  • Process Errors – Occur when a database operation (such as inserting or updating data) fails.

  • Session State Errors – Triggered when items are missing required values.

  • Application Errors – Generated by PL/SQL code, such as raising an exception.

Depending on the type of error, you can choose different display locations to make messages more visible and user-friendly.


Configuring Error Message Display Locations

APEX allows error messages to be displayed in different areas of a page. The most common locations are:

1. Inline with Field (Below or Above the Field)

  • This displays an error message directly below or above the field where the issue occurred.

  • Best for form-based validations where the user needs immediate feedback on incorrect input.

How to configure:

  1. Open Page Designer in APEX.

  2. Select the page item you want to validate.

  3. Scroll down to the Validation section and create a validation.

  4. In the Error Message settings, set Display Location to Inline with Field.

  5. Enter an error message, such as:

"Please enter a valid email address."

  1. Save and test the validation.

This method ensures the user can immediately see what needs to be corrected.


2. Inline with Notification (Displayed at the Top of the Page)

  • The error message appears in a red notification area at the top of the page.

  • Best for general form errors or when multiple fields need validation.

How to configure:

  1. Open Page Designer in APEX.

  2. Select the validation or process that triggers an error.

  3. In the Error Message settings, set Display Location to Inline with Notification.

  4. Enter a message, such as:
    "There are errors in the form. Please correct them before proceeding."

  5. Save and run the page.

This method ensures users see all errors at once before submitting the form again.


3. Inline in Notification Area (Displayed in the APEX Messages Area)

  • Displays errors in a predefined notification area on the page.

  • Useful for form-wide error handling where messages need to be centralized.

How to configure:

  1. Open Page Designer and navigate to the error-producing component.

  2. Under the Error Message section, select Inline in Notification Area.

  3. Save and test the feature.

This method works well when you want error messages to be consistent with other APEX notifications.


4. Displayed in an Alert Box

  • Shows the error in a JavaScript popup alert message.

  • Best for immediate user attention, such as critical validation failures.

How to configure using Dynamic Actions:

  1. In Page Designer, create a Dynamic Action for the button that submits the form.

  2. Set the event to Click and select the button.

  3. Add a True Action and select Execute JavaScript Code.

  4. Enter the following JavaScript code:

alert("Please correct the errors before submitting the form.");

  1. Save and test the form.

This method is useful for critical errors where users must acknowledge the message before continuing.


5. PL/SQL Custom Error Messages (Raise an Exception)

  • Allows developers to customize error messages in PL/SQL processes.

  • Best for database-related errors like duplicate entries or missing required data.

Example:

DECLARE

    v_count NUMBER;

BEGIN

    SELECT COUNT(*) INTO v_count FROM USERS WHERE EMAIL = :P1_EMAIL;

    

    IF v_count > 0 THEN

        RAISE_APPLICATION_ERROR(-20001, 'This email is already registered.');

    END IF;

END;

When the error is raised, APEX displays the message at the notification area by default.

To make the error display in a different location, wrap the error handling in apex_error.add_error:

BEGIN

    IF :P1_AGE < 18 THEN

        apex_error.add_error (

            p_message => 'Age must be 18 or older.',

            p_display_location => apex_error.c_inline_in_notification

        );

    END IF;

END;

This approach allows developers to control where and how errors are shown in APEX.


Best Practices for Displaying Error Messages

  • Use Inline with Field for errors related to individual form fields.

  • Use Inline with Notification for multiple errors in a form.

  • Use Alert Boxes for urgent or immediate attention.

  • Use Custom PL/SQL Messages for database errors and business rules.

  • Provide Clear Error Messages – Instead of "Invalid Input," use "Please enter a valid phone number."

  • Avoid Overloading Users – Too many messages at once can be confusing. Keep messages concise and relevant.


Oracle APEX provides multiple ways to display error messages, allowing developers to improve usability and user experience. By selecting the appropriate error display location, users can easily identify and correct errors, making applications more intuitive and user-friendly.


How Do I Associate a Validation with a Specific Item

 Associating a Validation with a Specific Item in Oracle APEX

Validations ensure that user inputs meet specific requirements before data is processed or saved. In Oracle APEX, you can associate a validation with a specific page item to ensure that the validation applies only to that field.

This tutorial explains how to create and associate different types of validations with a specific item in APEX, along with best practices for improving the user experience.


Understanding Item-Specific Validations

When creating a validation in APEX, you can associate it with a specific item so that it only triggers when that item is interacted with.

Validations can be applied to:

  • Text fields (e.g., ensuring a name is not empty)

  • Number fields (e.g., checking if a value is within a range)

  • Select lists (e.g., ensuring a selection is made)

  • Date pickers (e.g., checking if a date is in the future)

Each validation can be triggered on form submission, ensuring incorrect data is not processed.


Creating a Validation for a Specific Item

Step 1: Open Page Designer

  1. Navigate to App Builder and open your application.

  2. Select the page where the validation should be applied.

  3. In Page Designer, locate the item you want to validate (e.g., P1_EMAIL).


Step 2: Creating a Required Field Validation

To ensure a field is not left empty, create a Not Null validation.

  1. Select the P1_EMAIL item.

  2. Scroll down to the Validation section and click Create.

  3. Choose Validation Type as Not Null.

  4. Set the Associated Item to P1_EMAIL.

  5. Enter an Error Message, such as:

"Email address is required. Please enter a valid email."

  1. Click OK, then Save and Run the Page.

  2. Test by submitting the form without entering an email. The error message should appear.


Step 3: Validating Email Format with a Regular Expression

To ensure a user enters a valid email address, use a Regular Expression validation.

  1. Select the P1_EMAIL item in Page Designer.

  2. Go to the Validation section and click Create.

  3. Choose Validation Type as Regular Expression.

  4. Set the Expression to:

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$

  1. Set the Associated Item to P1_EMAIL.

  2. Enter an Error Message, such as:

"Invalid email format. Please enter a valid email address."

  1. Click OK, then Save and Run the Page.

  2. Test by entering an invalid email to see the error message.


Step 4: Checking If a Value Exists in the Database

To prevent duplicate entries, use a PL/SQL Function Returning Boolean validation.

  1. Select the P1_USERNAME item in Page Designer.

  2. Go to the Validation section and click Create.

  3. Choose Validation Type as PL/SQL Function Returning Boolean.

  4. Enter the following PL/SQL code:

DECLARE

    v_count NUMBER;

BEGIN

    SELECT COUNT(*) INTO v_count 

    FROM USERS 

    WHERE USERNAME = :P1_USERNAME;


    RETURN v_count = 0;

END;

  1. Set the Associated Item to P1_USERNAME.

  2. Enter an Error Message, such as:

"This username is already taken. Please choose another."

  1. Click OK, then Save and Run the Page.

  2. Test by entering a duplicate username to trigger the validation.


Step 5: Validating a Number Field

To ensure a user enters a number within a certain range, use a SQL Expression validation.

  1. Select the P1_AGE item in Page Designer.

  2. Go to the Validation section and click Create.

  3. Choose Validation Type as SQL Expression.

  4. Enter the condition:

:P1_AGE BETWEEN 18 AND 65

  1. Set the Associated Item to P1_AGE.

  2. Enter an Error Message, such as:

"Age must be between 18 and 65."

  1. Click OK, then Save and Run the Page.

  2. Test by entering an invalid age to trigger the validation.


Best Practices for Item-Specific Validations

  • Always associate validations with a specific item to provide clear error messages.

  • Use Not Null validations for required fields.

  • Use Regular Expressions for format validations (e.g., email, phone numbers).

  • Use PL/SQL for database-related validations (e.g., checking for duplicates).

  • Use SQL Expressions for range-based validations.

  • Always provide friendly error messages to guide the user.


Associating validations with specific items in APEX ensures that data is accurate before submission. By using Not Null, Regular Expressions, PL/SQL, and SQL Expressions, you can enforce rules and provide meaningful feedback to users. This helps prevent errors and improves the overall user experience.


EXAMPLE NOTES

To associate an item with a validation and specify error message text:

  1. View the page in Page Designer:

    1. On the Workspace home page, click the App Builder icon.

    2. Select an application.

    3. Select a page.

  2. Page Designer appears.

  3. In Page Designer, select the Processing tab in the left pane.

  4. Under Validating, select the validation you want to associate.The Property Editor displays Validation attributes.

  5. Under Validation, edit the following attributes:Error, Error Message - Enter the text to be displayed in the event that the validation does not pass.

  6. Error, Display Location - Select where the error message displays for this validation. Validation error messages display on a separate error page, or inline with the existing page. Inline error messages display underneath the associated item label or in a notification area defined as part of the page template.

How Do I Make a Faceted Search Map Page in Oracle APEX

Combining faceted search with a map region in Oracle APEX enables users to filter data visually and spatially at the same time. This design ...