!--a11y-->
Messages 
Messages are language-specific texts that are displayed on the screen if an error occurred during the execution of an application. The messages are defined at the level of a Web Dynpro component. Normally, a message is displayed in the status bar. If several messages are to be displayed, they are shown in a table. You can create and edit the messages using the Web Dypro Tool Message Editor. As is the case with other language-specific resources, the Web Dynpro framework generates specific interfaces and XML files that enable you to access the texts created in the Message Editor. See also: Message Editor.
Additional information is available under Creating and Editing a Message, Handling Errors and Error Messages, and Internationalization of a Web Dynpro Application.
One or more errors are reported to the user if:
· The message manager is called, which is represented by the interface IWDMessageManager
· An exception is raised that originates from an object of the class WDNonFatalRuntimeException
The message manager provides a number of methods that generate different error messages and allow different user interactions to correct the errors.
Some raise and reportmethods of the interface IWDMessageManager pass the keys of the error messages as parameters, as shown in the following source code for the method reportInvalidContextAttributeMessage. The keys are generated as constants of the type IWDMessage in the interface IMessage<Web Dynpro component name>.java.
|
public void reportInvalidContextAttributeMessage( IWDNodeElement element, String attributeName, IWDMessage messageItem, Object[] args);
|
The following source code represents a typical example of using messages.
The code calls the method reportInvalidContextAttributeMessage, which outputs an error message if the value of a context attribute becomes invalid. The message that is displayed was created in the Web Dynpro component SimpleErrors. The MISSING_INPUT key for the message text “Input is missing!“ is stored as a variable in the interface IMessageSimpleErrors.
|
public void checkMandatory( java.lang.String fieldName ) { //@@begin CheckMandatory() IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager(); Object attributeValue = wdContext.currentContextElement().getAttributeValue(fieldName); if (attributeValue instanceof String) { if (((String)attributeValue).length() == 0) { String fieldLabel = wdContext. getNodeInfo(). getAttribute(fieldName).getDataType().getFieldLabel(); msgMgr.reportInvalidContextAttributeMessage( wdContext.currentContextElement(),fieldName, IMessageSimpleErrors.MISSING_INPUT, new Object[] {fieldLabel}); } } //@@end } |
