com.sun.rave.web.ui.util
Class MessageUtil

java.lang.Object
  extended by com.sun.rave.web.ui.util.MessageUtil

public class MessageUtil
extends java.lang.Object

Factory class for retrieving server-side i18n messages within the JSF framework. Note that the ServletResponse locale, content type, and character encoding are not set here. Since tags may be used outside the Sun Web Console, that task will most likely be done in the console's session filter.

Example:

ResponseWriter w = FacesContext.getCurrentInstance().getResponseWriter(); w.write(MessageUtil.getMessage("com.sun.rave.web.ui.Resources", "key"));


Constructor Summary
protected MessageUtil()
           
 
Method Summary
static java.lang.ClassLoader getCurrentLoader(java.lang.Object o)
          Get current class loader from given object.
protected static java.lang.String getFormattedMessage(java.lang.String message, java.lang.Object[] args)
          Format message using given arguments.
protected static java.util.Locale getLocale()
          Get locale from current FacesContext instance.
protected static java.util.Locale getLocale(javax.faces.context.FacesContext context)
          Get locale from given FacesContext object.
static java.lang.String getMessage(javax.faces.context.FacesContext context, java.lang.String baseName, java.lang.String key)
          Get a message from a desired resource bundle.
static java.lang.String getMessage(javax.faces.context.FacesContext context, java.lang.String baseName, java.lang.String key, java.lang.Object[] args)
          Get a formatted message from a desired resource bundle.
static java.lang.String getMessage(java.util.Locale locale, java.lang.String baseName, java.lang.String key, java.lang.Object[] args)
          Get a formatted message from a desired resource bundle.
static java.lang.String getMessage(java.util.Locale locale, java.lang.String baseName, java.lang.String key, java.lang.Object[] args, java.lang.ClassLoader loader)
          Get a formatted message from a desired resource bundle.
static java.lang.String getMessage(java.lang.String baseName, java.lang.String key)
          Get a message from a desired resource bundle.
static java.lang.String getMessage(java.lang.String baseName, java.lang.String key, java.lang.Object[] args)
          Get a formatted message from a desired resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageUtil

protected MessageUtil()
Method Detail

getMessage

public static java.lang.String getMessage(javax.faces.context.FacesContext context,
                                          java.lang.String baseName,
                                          java.lang.String key)
Get a message from a desired resource bundle.

Parameters:
context - The FacesContext object used to obtain locale.
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
Throws:
java.lang.NullPointerException - if context or baseName is null.

getMessage

public static java.lang.String getMessage(javax.faces.context.FacesContext context,
                                          java.lang.String baseName,
                                          java.lang.String key,
                                          java.lang.Object[] args)
Get a formatted message from a desired resource bundle.

Parameters:
context - The FacesContext object used to obtain locale.
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
args - The arguments to be inserted into the string.
Throws:
java.lang.NullPointerException - if context or baseName is null.

getMessage

public static java.lang.String getMessage(java.lang.String baseName,
                                          java.lang.String key)
Get a message from a desired resource bundle.

Parameters:
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
Throws:
java.lang.NullPointerException - if baseName is null.

getMessage

public static java.lang.String getMessage(java.lang.String baseName,
                                          java.lang.String key,
                                          java.lang.Object[] args)
Get a formatted message from a desired resource bundle.

Parameters:
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
args - The arguments to be inserted into the string.
Throws:
java.lang.NullPointerException - if baseName is null.

getMessage

public static java.lang.String getMessage(java.util.Locale locale,
                                          java.lang.String baseName,
                                          java.lang.String key,
                                          java.lang.Object[] args)
Get a formatted message from a desired resource bundle.

Parameters:
locale - The locale for which a resource bundle is desired.
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
args - The arguments to be inserted into the string.
Throws:
java.lang.NullPointerException - if locale or baseName is null.

getMessage

public static java.lang.String getMessage(java.util.Locale locale,
                                          java.lang.String baseName,
                                          java.lang.String key,
                                          java.lang.Object[] args,
                                          java.lang.ClassLoader loader)
Get a formatted message from a desired resource bundle.

Parameters:
locale - The locale for which a resource bundle is desired.
baseName - The fully qualified name of the resource bundle.
key - The key for the desired string.
args - The arguments to be inserted into the string.
loader - The class loader used to load the resource bundle.
Throws:
java.lang.NullPointerException - if locale, baseName, or loader is null.

getFormattedMessage

protected static java.lang.String getFormattedMessage(java.lang.String message,
                                                      java.lang.Object[] args)
Format message using given arguments.

Parameters:
message - The string used as a pattern for inserting arguments.
args - The arguments to be inserted into the string.

getLocale

protected static java.util.Locale getLocale()
Get locale from current FacesContext instance.


getLocale

protected static java.util.Locale getLocale(javax.faces.context.FacesContext context)
Get locale from given FacesContext object.

Parameters:
context - The FacesContext object used to obtain locale.

getCurrentLoader

public static java.lang.ClassLoader getCurrentLoader(java.lang.Object o)
Get current class loader from given object.

Parameters:
o - Object used to obtain fallback class loader.