This section describes the requirements necessary to enable messages to display in the message bar being used by both the server-side code and client-side code.

Server-Side Configuration

Before configuring messages, ensure that the exception collector servlet has been activated in the application by inserting it in the servlet pipeline and adding the following lines to the web.xml file:

<context-param>
  <param-name>exception-collecting-enabled</param-name>
  <param-value>true</param-value>
</context-param>

The exception collector servlet creates messages from DropletException and ServletException objects that occur in the request.

Adding Messages from a Form Handler

There are two methods you can use to add messages to the messaging UI from a form handler:

The messaging UI will also display unhandled exceptions from the form handlers and server-side business logic.

Message Properties

Messages have the following properties:

When one or more exceptions occur during either a form handler exceptions or an unhandled servlet exception, a single message is created with type = “error”. Each exception is added as a detail within the message. All exceptions that occur during a request are grouped inside a single container message. When no exceptions occur during the request, and a success summary is specified via the request parameters, the messaging UI creates a confirmation message.

Specifying a Message Summary

Success and failure summaries are specified using the atg.successMessage and atg.failureMessage parameters. For example, to specify message summaries with a form enter:

<input name="atg.successMessage" type="hidden" value="Updated info
  for John Doe."/>
<input name="atg.failureMessage" type="hidden" value="There was a
  problem updating John Doe's info."/>

If no failure summary is specified in the request, the messaging UI adds the default summary specified in the message bar:

<div dojoType="messaging:MessageBar" errorMessage="There were
  errors with the request."/>

By default, no message is displayed for successful requests.

Adding Messages from JavaScript

You can add messages from JavaScript code by using the message bar addMessage function:

dojo.widget.byId('messageBar').addMessage({type:"warning", summary:"An
error has occurred."});

To add a message with bulleted details, use JavaScript similar to the following:

dojo.widget.byId('messageBar').addMessage({type:"error", summary:"An
error has occurred.", details:[{description: "First detail"},
{description: "Second detail"}]});
 
loading table of contents...