Entering content frame

Process documentation Error Handling Locate the document in its SAP Library structure

The interface IWDMessageManager enables you to handle messages and can be used to display information or report errors on the screen. Using relevant methods and depending on the message type, the runtime environment provides the user with a dialog with the Web Dynpro application. Error messages and other messages can be displayed by calling a method of the message manager. The message manager provides a number of methods that allow the generation of different error messages and different user interactions to correct the errors.

Error and message handling is closely linked with event handling, validation, and a request/response process of a query sent to the server. The runtime environment processes a specific sequence of phases – that is, specific program steps – that are executed within a request/response process. In the case of errors that occur when the message manager IWDMessageManager is called or when an exception WDNonFatalRutimeException is raised, the subsequent phases of a current request/response process are no longer processed. For example, the system highlights the errors so that the user can easily correct errors caused by incorrect input (see following description). Afterwards, all subsequent phases of the request/response process can be executed.

Detailed information about creating, editing, and changing messages is available under:

·        Messages

·        Processing a Message



Simple, String-Based Methods of the Message Manager

/**

  * Report error message <code>message</code>..

 *

 * @param message is the human readable message that will be
 * displayed on the client. Success phase of the Web Dynpro
 * request / response cycle are not executed anymore

 */

  public void reportException(String message);

 

/**

 * Report warning message <code>message</code>.

 *

 * @param message is the human readable message that will be displayed
 * on the client

 */

  public void reportWarning(String message);

     

/**

 * Report an message <code>message</code>.

 *

 * @param message is the human readable message that will be displayed
 * on the client

 */

  public void reportSuccess(String message);

 

Context-Specific Methods of the Message Manager

In many cases, an error is caused by invalid data input by the user. To help the user correct invalid data, the message manager IWDMessageManager provides a number of methods that allow you to link errors or warnings with a specific context attribute. In this case, the error is not signified by a simple error message, but instead the UI element that is linked with the invalid context attribute is highlighted – that is, is framed in red. Furthermore, you can simply choose the error message and are then automatically taken to a UI element. You can then correct the error. To link a context attribute with a specific warning or error, the message manager provides a number of methods with which you can pass a node element and the name of the context attribute as a parameter. The naming convention for methods that can be linked with a context attribute is:
reportInvalidContextAttribute<method suffix>.

For example:

public void reportInvalidContextAttributeException(

IWDNodeElement element,

String attributeName,

WDNonFatalException ex );

 

public void reportInvalidContextAttributeException(

IWDNodeElement element,

String attributeName,

String message );

 

Message-Based Methods of the Message Manager

The following introduces some message-based methods of the message manager:

/**

  * Report a message item caused by an invalid context attribute
  * value.
  *

  * @param element is a reference to the context node element
  * containing the invalid attribute

  * @param attributeName is the name of the attribute which is invalid

  * @param messageItem is the message associated with the context
   * attribute

  * @param args are the arguments for the message parameters in the
   * same way as used in @see java.text.MessageFormat

  */

  public void reportInvalidContextAttributeMessage(

IWDNodeElement element, String attributeName, IWDMessage messageItem, Object[] args);

 

/**

  * Raises a message caused by an invalid context attribute value. This
  * method
internally raises a Runtime exception and execution

  * continues in the Web Dynpro framework. It is not recommended to
  * call this method with warnings

  * and success messages.

  *

  * @param messageItem is the message associated with the context

  * attribute

  * @param args are the arguments for the message parameters in the
   * same way as used in @see java.text.MessageFormat

  */

  public void raiseMessage(IWDMessage messageItem, Object[] args);

 

 /**

   * Report a message item caused by an invalid context attribute
   * value.Depending on the type of the message item

   * and on user settings this method may either return or raise a
   * runtime exception in order to return to the

   * framework error handling.

   *

   *

   * @param messageItem is the message associated with the context
   * attribute

   * @param args are the arguments for the message parameters in the
   * same way as used in @see java.text.MessageFormat

   */

  public void reportMessage(IWDMessage messageItem, Object[] args);

 

 

Raise and Report Methods

Most of the methods provided by the message manager are available both as raise and as report methods. The difference between these methods is that:

·        Report methods save the message and pass it back to the object that called the method

·        Raise methods also save the message, but do not pass it back to the object that called the method. Instead, they interrupt the current execution phase and proceed directly to the error handling.
The
raise methods are not returned to the object that called them, since the runtime environment raises a private exception.

Caution

Other methods should not be used for the error handling of a Web Dynpro application.

If you use report methods, you can output several errors within a single request/response cycle. This means that all errors are displayed at the same time. The user can correct errors in a single step and does not have to process any additional requests.

  

  

 

 

Leaving content frame