Skip Headers

Oracle® Application Development Framework Developer's Guide 10g Release 3 (10.1.3) B25386-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# 12.7 Displaying Error Messages

By default, ADF Faces validation and conversion run on the client side. As soon as one component's data fails validation, a dialog displays an error message for that 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 with a `required` attribute set to `true`.

Figure 12-4 A Client-Side Error Message

ADF Faces provides default text for messages displayed when validation fails. You can replace the default with your own message by setting the message attributes of the validator or converter with different text, 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 a `messages` tag at the top of the page. This tag can display all validation 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 layer error messages. ADF Model layer messages are shown first. Messages are shown both within the messages tag and with the associated components. Figure 12-5 shows the error message for an ADF Model layer 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 Using the message Tag

## 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 `messages` tag. When you drop any item from the Data Control Palette onto a page as an input component, JDeveloper automatically adds this tag. You must then configure the tag.

To display error messages in an error box:

1. In the Structure window, select the `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 below the `body` tag:

       <af:messages globalOnly="false" />

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 title of the message box.

3. Ensure that client-side validation has been disabled. If you do not disable client-side validation, the dialog message box 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 component. This attribute displays the detail error message next to the component. The message is also displayed by the optional `messages` tag, which displays all summary messages in a message box.