Skip Headers
Oracle® Application Development Framework Developer's Guide
10g (10.1.3.1.0)

Part Number B28967-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

12.7 Displaying Error Messages

By default, ADF Faces validation and conversion run on the client side. When a component's data fails validation, an alert dialog displays an error message for the component. You do not need to do any additional work to have client-side error messages display in this way. Figure 12-4 shows the message displayed when data is not entered for an input component that has a required attribute set to true.

Figure 12-4 A Client-Side Error Message

An error message displays in a pop-up dialog.

ADF Faces provides default text for messages displayed when validation or conversion fails. You can replace the default messages with your own messages by setting the text on the xxxMessageDetail attributes of the validator or converter (such as convertDateMessageDetail or notInRangeDetailMessage), or by binding those attributes to a resource bundle using an EL expression. For more information about using resource bundles, see Section 14.4.1, "How to Internationalize an Application".

When you use the Data Control Palette to create input components, JDeveloper inserts the af:messages tag at the top of the page. This tag can display all error messages in the queue for any validation that occurs on the server side, in a box offset by color. If you choose to turn off client-side validation for ADF Faces, those error messages are displayed along with any ADF Model error messages. ADF Model messages are shown first. Messages are shown both within the af:messages tag and with the associated components.

Figure 12-5 shows the error message for an ADF Model validation rule, which states that the description is too long, along with an error message for an ADF Faces component required attribute violation.

Figure 12-5 Displaying Server-Side Error Messages With the ADF Faces Messages Tag

Messages display at the top of the page and below components

12.7.1 How to Display Server-Side Error Messages on a Page

You can display server-side error messages in a box at the top of a page using the af:messages tag. When you drop any item from the Data Control Palette onto a page as an input component, JDeveloper automatically adds this tag for you.

To display error messages in an error box:

  1. In the Structure window, select the af:messages tag.

    This tag is created automatically whenever you drop an input widget from the Data Control Palette. However, if you need to insert the tag, simply insert the following code within the afh:body tag:

    <afh:body>
      <af:messages globalOnly="false" />
      ...
    </afh:body>
    
    
  2. In the Property Inspector set the following attributes:

    • globalOnly: By default ADF Faces displays global messages (i.e., messages that are not associated with components) followed by individual component messages. If you wish to display only global messages in the box, set this attribute to true. Component messages will continue to display with the associated component.

    • message: The main message text that displays just below the message box title, above the list of individual messages.

    • text: The text that overrides the default title of the message box.

  3. Ensure that client-side validation has been disabled. If you do not disable client-side validation, the alert dialog will display if there are any ADF Faces validation errors, as the server-side validation will not have taken place.


    Tip:

    To disable client-side validation, add the <client-validation-disabled> element in adf-faces-config.xml and set it to true.

12.7.2 What Happens When You Choose to Display Error Messages

When a conversion or validation error occurs on an ADF Faces input component, the component creates a FacesMessage object and adds it to a message queue on the FacesContext instance. During the Render Response phase, the message associated with the validator or converter is displayed using the built-in message display attribute for the ADF Faces input component. This attribute displays the detail error message next to the component. The message is also displayed by the optional af:messages tag, which displays all summary messages in a message box.