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.
For more information see
· Creating and Editing a Message
· Handling Errors and Error Messages and
· Internationalization of Web Dynpro Projects.
...
1. Displaying Messages
to the User
The runtime environment offers users a dialog with the Web Dynpro application
using the appropriate methods and depending on the message type. Three
different message types, which also appear differently on the user interface,
are available to display messages :
· error
· standard
· warning
For more information see Example for Using Messages.
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 report methods of interface IWDMessageManagerpass the keys of the error messages as parameters, as shown in the following source text for method reportMessage. The keys are generated as constants of the type IWDMessage in the interface IMessage<Web Dynpro component name>.java.
public void reportMessage(IWDMessage messageItem, Object[] args), boolean cancelNavigation; |
You can see an example in Example for Using Messages.
2. Displaying Texts
You can use messages of type text for example to label a UI element that was created dynamically. If you only want to show a pushbutton at runtime, you cannot label the pushbutton at design time:
1. You therefore create the text to be displayed at runtime in the message editor as described in Creating and Editing a Message.
2.
You specify a message key, enter the text to be
displayed, and select text as the message type, for example
3. You save all the metadata.
4.
With the following source text for the controller
implementation of an example view MainView you can create a pushbutton at
runtime whose label is read with message key KEY1 and for which “Save
input” is displayed as the text of the pushbutton
(see the screen copy of the pushbutton: ).
public static void wdDoModifyView(IprivateMainView wdThis, IPrivateMainView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime) { //@@begin wdDoModifyView if (firstTime) { IWDButton button =(IWDButton) view.createElement(IWDButton.class, "MyButton"); button.setText(wdComponentAPI.getTextAccessor().getText("KEY1")); IWDTransparentContainer container=(IWDTransparentContainer) view.getElement("RootUIElementContainer"); container.addChild(button); } |
The messages can be called with the following source text. The text or tooltip is set for a root node element.
public void wdDoInit() { IWDTextAccessor textAccessor = wdComponentAPI().getTextAccessor(); wdContext.currentContextElement.setText(textAccessor.getText("TEST_KEY_FOR_TEXT", new Object[]{ "test" } ));
wdContext.currentContextElement().setTooltip(textAccessor.getText("TEST_KEY_FOR_TOOLTIP")); //@@end } |