Class 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 Detail

      • MessageManager

        public MessageManager()
    • 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)
      • setLanguage

        public static void setLanguage​(String language)
      • getLanguage

        public static String getLanguage()
      • setLanguage

        protected static void setLanguage​(String registredKey,
                                          String language)
      • getLanguage

        protected static String getLanguage​(String registredKey)
      • 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.
      • 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 key
        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

        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 key
        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

        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 key
        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

        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 key
        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

        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 key
        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).