Class MessageManager
- java.lang.Object
-
- org.silverpeas.core.notification.message.MessageManager
-
public class MessageManager extends Object
This manager provides tools to register and restitute volatile messages (info, success or error) to the user (on screen).It works for now with Thread Cache Service, and several steps have to be performed : - use the initialize function in order to render accessible message tools provided - user message tools in treatment when necessary - use the destroy function in order to clear all message data attached to the thread
A typical initialization/destruction in a the service method of a HttpServlet : protected void service(HttpHttpServletResponse response) {
MessageManager.initialize(); try { ... } finally { MessageManager.destroy(); ... } }
A typical use anywhere in treatments :
if ([test of functionnal information is not ok]) { MessageMessager.addError(bundle.getMessage("err.label", params)); }
- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description MessageManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Message
addError(String message)
Add an error message.protected static Message
addError(String registredKey, String message)
Add an error message.static Message
addInfo(String message)
Add an info message.protected static Message
addInfo(String registredKey, String message)
Add an info message.protected static void
addListener(String registredKey, MessageListener listener)
static void
addListener(MessageListener listener)
static Message
addSevere(String message)
Add an severe message.protected static Message
addSevere(String registredKey, String message)
Add an severe message.static Message
addSuccess(String message)
Add a success message.protected static Message
addSuccess(String registredKey, String message)
Add a success message.static Message
addWarning(String message)
Add an warning message.protected static Message
addWarning(String registredKey, String message)
Add an warning message.static void
clear(String registredKey)
static void
destroy()
Clear out the thread cache the registered key referenced.static String
getLanguage()
protected static String
getLanguage(String registredKey)
static org.silverpeas.kernel.bundle.LocalizationBundle
getLocalizationBundle(String bundleBaseName)
Gets the localization bundle with the given base name and for the root locale.protected static org.silverpeas.kernel.bundle.LocalizationBundle
getLocalizationBundle(String messageContainerName, String bundleBaseName, String language)
Gets from the message container the localization bundle with the specified bundle base name and for the given language.static MessageContainer
getMessageContainer(String registredKey)
static String
getRegistredKey()
static String
initialize()
static void
setLanguage(String language)
protected static void
setLanguage(String registredKey, String language)
-
-
-
Method Detail
-
initialize
public static String initialize()
-
destroy
public static void destroy()
Clear out the thread cache the registered key referenced.
-
addListener
public static void addListener(MessageListener listener)
-
addListener
protected static void addListener(String registredKey, MessageListener listener)
-
setLanguage
public static void setLanguage(String language)
-
getLanguage
public static String getLanguage()
-
clear
public static void clear(String registredKey)
-
getRegistredKey
public static String getRegistredKey()
-
getLocalizationBundle
public static org.silverpeas.kernel.bundle.LocalizationBundle getLocalizationBundle(String bundleBaseName)
Gets the localization bundle with the given base name and for the root locale.- Parameters:
bundleBaseName
- the localization bundle base name.- Returns:
- a localization bundle.
-
getLocalizationBundle
protected static org.silverpeas.kernel.bundle.LocalizationBundle getLocalizationBundle(String messageContainerName, String bundleBaseName, String language)
Gets from the message container the localization bundle with the specified bundle base name and for the given language.- Parameters:
messageContainerName
- the name of the message container.bundleBaseName
- the base name of the localization bundle.language
- the language for which the bundle is asked.- Returns:
- a localization bundle.
-
getMessageContainer
public static MessageContainer getMessageContainer(String registredKey)
-
addError
public static Message addError(String message)
Add an error message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
message
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addError
protected static Message addError(String registredKey, String message)
Add an error message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
registredKey
- the keymessage
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addSevere
public static Message addSevere(String message)
Add an severe message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
message
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addSevere
protected static Message addSevere(String registredKey, String message)
Add an severe message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
registredKey
- the keymessage
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addWarning
public static Message addWarning(String message)
Add an warning message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
message
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addWarning
protected static Message addWarning(String registredKey, String message)
Add an warning message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
registredKey
- the keymessage
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addSuccess
public static Message addSuccess(String message)
Add a success message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
message
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addSuccess
protected static Message addSuccess(String registredKey, String message)
Add a success message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
registredKey
- the keymessage
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addInfo
public static Message addInfo(String message)
Add an info message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
message
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
addInfo
protected static Message addInfo(String registredKey, String message)
Add an info message. If a message already exists, HTML newline is added between the existent message and the given one- Parameters:
registredKey
- the keymessage
- message to add- Returns:
- the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).
-
-