!--a11y-->
Defining
Messages 
The Web Dynpro tools provide a special Message Editor for defining messages of different types.

A message is defined by a specified key, message type, and message text. The three message types error, warning, and standard are predefined. At runtime, messages of different types are displayed in the Web browser using an appropriate layout – for example, specific icons for error, warning, or standard.
The message texts can contain arguments. The format of these arguments is defined by the specifications of the java.text.MessageFormat class.
A Java class IMessage<ComponentName> is generated using the messages defined in the Message Editor. This class contains each message as a constant. Message texts can be output at runtime according to the defined settings using the IWDMessageManager interface. The corresponding arguments must be passed for each defined message. The access to the message texts is key-based, the message texts themselves are stored in separate files after the translation process for different languages.
An example: In the Message Editor, you define a message of the type error using the MissingInput key. The message text contains the label text for the entry field as an argument. This argument is marked by {0}.
Message Defined in the Message Editor |
||
Message Key |
Message Type |
Message Text |
MissingInput |
error |
{0}: Entry of a valid {0} is required for proceeding with the requested service. |
You can display the defined message in the implementation of the view controller using the method reportContextAttributeMessage()of the IWDMessageManager interface. The message is contained in the generated IMessageSimpleErrors interface as a constant called MISSING_INPUT. The value of the argument {0} is passed in the array {"Name"}.
Implementation of the View Controller |
... IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager(); msgMgr.reportContextAttributeMessage( this.wdContext.currentContextElement(), attributeInfo, IMessageSimpleErrors.MISSING_INPUT, new Object[] {"Name"}, true); ...
|
After executing this source code, the error message is displayed on the user interface in the Web browser, as follows:

...
1.
Select the
Message Editor of the Web Dynpro component SimpleErrors by
choosing the node
Message Pool
in the Web Dynpro Explorer:
2.
Add the following
three messages using the
button in the Message
Editor:
3.
Messages Defined in the Message Editor |
||
Message Key |
Message Type |
Message Text |
DateIsInFuture |
error |
Please enter a valid date for field {0}. You entered {1}, which is a date in the future and therefore not a valid date of birth. |
DesiredEMail |
warning |
You did not enter an e-mail address. Therefore, you will not be informed about product news and special offers. |
MissingInput |
error |
{0}: Entry of a valid {0} is required for proceeding with the requested service. |
The
next step is to implement methods for
error handling and the action event handlers in the controller of the view
form.
