org.apache.myfaces.commons.util
Class MessageUtils

java.lang.Object
  extended by org.apache.myfaces.commons.util.MessageUtils

public final class MessageUtils
extends Object

Utility class to support multilingual FacesMessages using ResourceBundles. Standard messages are stored at DEFAULT_BUNDLE.
The summary of the message is stored at the requested key value. The detail of the message is stored at <messageId>_detail.

Version:
$Revision: 1034621 $ $Date: 2010-11-12 20:34:04 -0500 (Fri, 12 Nov 2010) $
Author:
Thomas Spiegl (latest modification by $Author: lu4242 $), Manfred Geiler, Sean Schofield, Stpehan Strittmatter
See Also:
FacesMessage, ResourceBundle

Method Summary
static void addMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args)
           
static void addMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, javax.faces.context.FacesContext facesContext)
           
static void addMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, String forClientId)
           
static void addMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, String forClientId, javax.faces.context.FacesContext facesContext)
           
static void addMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args)
           
static void addMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, javax.faces.context.FacesContext facesContext)
           
static void addMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, String forClientId)
           
static void addMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, String forClientId, javax.faces.context.FacesContext facesContext)
           
static Locale getCurrentLocale()
           
static Locale getCurrentLocale(javax.faces.context.FacesContext context)
           
static Object getLabel(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.context.FacesContext context, String messageId)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.context.FacesContext context, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object arg)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, javax.faces.context.FacesContext facesContext)
           
static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity, String bundleBaseName, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(Locale locale, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(ResourceBundle bundle, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, javax.faces.context.FacesContext context, String messageId)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, javax.faces.context.FacesContext context, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object arg)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, javax.faces.application.FacesMessage.Severity severity, String messageId, Object[] args, javax.faces.context.FacesContext facesContext)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, Locale locale, String messageId, Object[] params)
          Retrieve the message from a specific bundle.
static javax.faces.application.FacesMessage getMessage(String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessage(String bundleBaseName, String messageId, Object[] params)
          Retrieve the message from a specific bundle.
static javax.faces.application.FacesMessage getMessageFromBundle(String bundleBaseName, javax.faces.context.FacesContext context, Locale locale, String messageId, Object[] params)
           
static javax.faces.application.FacesMessage getMessageFromBundle(String bundleBaseName, String messageId, Object[] params)
           
static String substituteParams(Locale locale, String msgtext, Object[] params)
          Uses MessageFormat and the supplied parameters to fill in the param placeholders in the String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object arg)
Parameters:
severity - serverity of message
messageId - id of message
arg - arument of message
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object arg)

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object[] args)
Parameters:
severity - serverity of message
messageId - id of message
args - aruments of message
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object[] args)

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object[] args,
                                                              javax.faces.context.FacesContext facesContext)

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              javax.faces.application.FacesMessage.Severity severity,
                                                              String messageId,
                                                              Object[] args,
                                                              javax.faces.context.FacesContext facesContext)

addMessage

public static void addMessage(javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args)

addMessage

public static void addMessage(String bundleBaseName,
                              javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args)

addMessage

public static void addMessage(javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              javax.faces.context.FacesContext facesContext)

addMessage

public static void addMessage(String bundleBaseName,
                              javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              javax.faces.context.FacesContext facesContext)

addMessage

public static void addMessage(javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              String forClientId)

addMessage

public static void addMessage(String bundleBaseName,
                              javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              String forClientId)

addMessage

public static void addMessage(javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              String forClientId,
                              javax.faces.context.FacesContext facesContext)

addMessage

public static void addMessage(String bundleBaseName,
                              javax.faces.application.FacesMessage.Severity severity,
                              String messageId,
                              Object[] args,
                              String forClientId,
                              javax.faces.context.FacesContext facesContext)

substituteParams

public static String substituteParams(Locale locale,
                                      String msgtext,
                                      Object[] params)
Uses MessageFormat and the supplied parameters to fill in the param placeholders in the String.

Parameters:
locale - The Locale to use when performing the substitution.
msgtext - The original parameterized String.
params - The params to fill in the String with.
Returns:
The updated String.

getMessage

public static javax.faces.application.FacesMessage getMessage(String messageId,
                                                              Object[] params)

getMessageFromBundle

public static javax.faces.application.FacesMessage getMessageFromBundle(String bundleBaseName,
                                                                        String messageId,
                                                                        Object[] params)

getMessage

public static javax.faces.application.FacesMessage getMessage(Locale locale,
                                                              String messageId,
                                                              Object[] params)

getMessageFromBundle

public static javax.faces.application.FacesMessage getMessageFromBundle(String bundleBaseName,
                                                                        javax.faces.context.FacesContext context,
                                                                        Locale locale,
                                                                        String messageId,
                                                                        Object[] params)

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              String messageId,
                                                              Object[] params)
Retrieve the message from a specific bundle. It does not look on application message bundle or default message bundle. If it is required to look on those bundles use getMessageFromBundle instead

Parameters:
bundleBaseName - baseName of ResourceBundle to load localized messages
messageId - id of message
params - parameters to set at localized message
Returns:
generated FacesMessage

getCurrentLocale

public static Locale getCurrentLocale()
Returns:
currently applicable Locale for this request.

getCurrentLocale

public static Locale getCurrentLocale(javax.faces.context.FacesContext context)

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.application.FacesMessage.Severity severity,
                                                              String bundleBaseName,
                                                              String messageId,
                                                              Object[] params)
Parameters:
severity - severity of message
bundleBaseName - baseName of ResourceBundle to load localized messages
messageId - id of message
params - parameters to set at localized message
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              Locale locale,
                                                              String messageId,
                                                              Object[] params)
Retrieve the message from a specific bundle. It does not look on application message bundle or default message bundle. If it is required to look on those bundles use getMessageFromBundle instead

Parameters:
bundleBaseName - baseName of ResourceBundle to load localized messages
locale - current locale
messageId - id of message
params - parameters to set at localized message
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(ResourceBundle bundle,
                                                              String messageId,
                                                              Object[] params)
Parameters:
bundle - ResourceBundle to load localized messages
messageId - id of message
params - parameters to set at localized message
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.context.FacesContext context,
                                                              String messageId)
Parameters:
context -
messageId -
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              javax.faces.context.FacesContext context,
                                                              String messageId)

getMessage

public static javax.faces.application.FacesMessage getMessage(javax.faces.context.FacesContext context,
                                                              String messageId,
                                                              Object[] params)
Parameters:
context -
messageId -
params -
Returns:
generated FacesMessage

getMessage

public static javax.faces.application.FacesMessage getMessage(String bundleBaseName,
                                                              javax.faces.context.FacesContext context,
                                                              String messageId,
                                                              Object[] params)

getLabel

public static Object getLabel(javax.faces.context.FacesContext facesContext,
                              javax.faces.component.UIComponent component)


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.