Show TOC

Displaying User MessagesLocate this document in the navigation structure

Use

Depending on what source of message texts you use, you perform different steps to finally display the text on the screen in the required manner.

The following options are available:

  • displaying message of specified message types from the Message Pool

  • displaying message of unspecific message type Text from the Message Pool

  • displaying hard coded text string

Normally, a message is displayed below the current view assembly. You can define an other location for the messages by means of the MessageArea UI element.

Prerequisites
  • The initial component has been created and is displayed in the Web Dynpro Explorer view.

  • To display a message from the Message Pool, you have defined the message with the required message type there.

  • You have created the UI element, which triggers the user message, placed it in a view and bound it to a suitable context attribute.

  • You have created an action object in the same view.

Procedure
  1. In the event handler method of the action object, get the attribute value of the bound context attribute (here: MyMandatoryAttribute of node MyNode ).

  2. Get the reference of the Message Manager.

// get context attribute value

String myAttrib =

wdContext.currentMyNode().getMyMandatoryAttribute();

// read messages from the Message Manager

IWDMessageManager msgmgr =

wdComponentAPI.getMessageManager();

Displaying Message of Specified Message Types from Message Pool

  1. Display the message from the Message Pool, by referring to the message key indicating the message (here MY_ERROR for message key MyError ).

    Depending on the message type, the appropriate icon is displayed with the message.

// call message key MyError of type IWDMessage

// in Message Pool of component MyComp

msgmgr.reportContextAttributeMessage(

wdContext.currentMyNode().

getAttributePointer("MyMandatoryAttribute"), // bound attribute

IMessageMyComp. MY_ERROR , // message key

null );

Displaying Message of Unspecific Message Type Text from Message Pool

  1. Call the TextAccessor to display messages of type IWDText (here MY_TEXT , referring to message key MyText ).

  2. To display the message with the required icon, use the methods of the IWD MessageManager class:

    • reportSuccess()

    • reportWarning()

    • reportException()

// access TextAccessor to display message of type IWDText

myTextMessage =

wdComponentAPI.getTextAccessor().getText( IMessageMyComp. MY_TEXT );

// display text message as success message

msgmgr.reportSuccess(myTextMessage);

Displaying Hard Coded Text String

  1. Get the reference of the Message Manager.

  2. Display the text string using the appropriate method.

// read messages from the Message Manager

IWDMessageManager msgmgr =

wdComponentAPI.getMessageManager();

// display text message as success, warning and error message

msgmgr.reportSuccess ("Text of success message");

msgmgr.reportWarning("Text of warning message");

msgmgr.reportException("Text of error message ");