org.araneaframework.framework
Interface MessageContext

All Superinterfaces:
Serializable, UpdateRegionProvider
All Known Implementing Classes:
StandardMessagingFilterWidget

public interface MessageContext
extends UpdateRegionProvider

A context for adding messages to a central pool of messages for later output with a consistent look.

A good example is StandardMessagingFilterWidget. It registers a MessageContext in the environment and if a childservice needs to output a message which should have a consistent look (location on the screen, styles etc.) it adds the message via showMessage(String,String).

A widget can use the MessageContext from the environment to output the accumulated messages.

Permanent messages should stay in MessageContext until explicitly cleared, other messages should be cleared after the user has seen them once.

Author:
"Toomas Römer" , Jevgeni Kabanov (ekabanov at araneaframework dot org), Taimo Peelo (taimo@araneaframework.org)

Field Summary
static String ERROR_TYPE
          A message type indicating its an error message.
static String INFO_TYPE
          A message type indicating its an info message.
static String MESSAGE_REGION_KEY
           
static String WARNING_TYPE
          A message type indicating its an info message.
 
Method Summary
 void clearAllMessages()
          Clears all messages (both permanent and usual).
 void clearMessages()
          Clears all non-permanent messages.
 void clearPermanentMessages()
          Clears all of the permanent messages.
 Map getMessages()
          Returns all messages as a Map.
 void hideErrorMessage(String message)
          Hides an error message from user.
 void hideInfoMessage(String message)
          Hides an info message from user.
 void hideMessage(String type, String message)
          Removes a message message of type type.
 void hideMessages(String type, Set messages)
          Removes messages message of type type.
 void hidePermanentMessage(String message)
          Clears the specific permanent message, under all message types where it might be present.
 void hideWarningMessage(String message)
          Hides a warning message from user.
 void showErrorMessage(String message)
          Shows an error message to the user.
 void showInfoMessage(String message)
          Shows an informative message to the user.
 void showMessage(String type, String message)
          Shows a message message of type type to the user.
 void showMessages(String type, Set messages)
          Shows messages of given type to the user.
 void showPermanentMessage(String type, String message)
          Shows a permanent message message of type type to the user.
 void showWarningMessage(String message)
          Shows a warning message to the user.
 
Methods inherited from interface org.araneaframework.http.UpdateRegionProvider
getRegions
 

Field Detail

MESSAGE_REGION_KEY

public static final String MESSAGE_REGION_KEY
Since:
1.1
See Also:
Constant Field Values

ERROR_TYPE

public static final String ERROR_TYPE
A message type indicating its an error message.

See Also:
Constant Field Values

WARNING_TYPE

public static final String WARNING_TYPE
A message type indicating its an info message.

See Also:
Constant Field Values

INFO_TYPE

public static final String INFO_TYPE
A message type indicating its an info message.

See Also:
Constant Field Values
Method Detail

showMessage

public void showMessage(String type,
                        String message)
Shows a message message of type type to the user. Message is cleared after the user sees it once.


showMessages

public void showMessages(String type,
                         Set messages)
Shows messages of given type to the user. Messages are cleared after the user sees them once.

Parameters:
messages - Set<String>
Since:
1.1

hideMessage

public void hideMessage(String type,
                        String message)
Removes a message message of type type.

Since:
1.1

hideMessages

public void hideMessages(String type,
                         Set messages)
Removes messages message of type type.

Parameters:
messages - Set<String>
Since:
1.1

showErrorMessage

public void showErrorMessage(String message)
Shows an error message to the user.


hideErrorMessage

public void hideErrorMessage(String message)
Hides an error message from user.

Since:
1.1

showWarningMessage

public void showWarningMessage(String message)
Shows a warning message to the user.


hideWarningMessage

public void hideWarningMessage(String message)
Hides a warning message from user.

Since:
1.1

showInfoMessage

public void showInfoMessage(String message)
Shows an informative message to the user.


hideInfoMessage

public void hideInfoMessage(String message)
Hides an info message from user.

Since:
1.1

clearMessages

public void clearMessages()
Clears all non-permanent messages.


showPermanentMessage

public void showPermanentMessage(String type,
                                 String message)
Shows a permanent message message of type type to the user. The message will be shown until hidden explicitly.


hidePermanentMessage

public void hidePermanentMessage(String message)
Clears the specific permanent message, under all message types where it might be present.

Parameters:
message - to be removed from permanent messages

clearPermanentMessages

public void clearPermanentMessages()
Clears all of the permanent messages.


clearAllMessages

public void clearAllMessages()
Clears all messages (both permanent and usual).


getMessages

public Map getMessages()
Returns all messages as a Map. The keys of the Map are the different message types encountered so far and under the keys are the messages in a Collection.

A child service should do as follows to access the messages

 
 ...
 MessageContext msgCtx = (MessageContext) getEnvironment().requireEntry(MessageContext.class);
 Map map = msgCtx.getMessages();
 Collection list = (Collection) map.get(MessageContext.ERROR_TYPE); // collection contains all the error messages
 
 
The map could be null if this service was not used. The collection is null if no messages of that type been added to the messages.

Since:
1.1