Esri Geoportal Server
1.0

com.esri.gpt.framework.jsf
Class MessageBroker

java.lang.Object
  extended by com.esri.gpt.framework.jsf.MessageBroker

public class MessageBroker
extends Object

Retrieves messages based upon the resource bundle associated with the locale of the Faces view root.


Field Summary
static String DEFAULT_BUNDLE_BASE_NAME
          Default resource bundle that should be looked at
 
Constructor Summary
MessageBroker()
          Default constructor.
 
Method Summary
 void addErrorMessage(String resourceKey)
          Adds an error message to the Faces context.
 void addErrorMessage(String resourceKey, Object[] parameters)
          Adds an error message message to the Faces context.
 void addErrorMessage(Throwable t)
          Adds an error message to the Faces context based upon a thrown exception.
 void addMessage(FacesMessage message)
          Adds a message to the Faces context.
 void addSuccessMessage(String resourceKey)
          Adds a success message to the Faces context.
 void addSuccessMessage(String resourceKey, Object[] parameters)
          Adds a success message to the Faces context.
 String getBundleBaseName()
          Gets the base name for the resource bundle.
 Locale getLocale()
          Gets locale.
 FacesMessage getMessage(String resourceKey)
          Gets a message from a resource bundle.
 FacesMessage getMessage(String resourceKey, Object[] parameters)
          Gets a message from a resource bundle.
 String getResourceKeyPrefix()
          Gets the resource key prefix.
 String retrieveMessage(String resourceKey)
          Retrieves a message from a resource bundle.
 String retrieveMessage(String resourceKey, Object[] parameters)
          Retrieves a message from a resource bundle.
 void setBundleBaseName(String baseName)
          Sets the base name for the resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUNDLE_BASE_NAME

public static final String DEFAULT_BUNDLE_BASE_NAME
Default resource bundle that should be looked at

See Also:
Constant Field Values
Constructor Detail

MessageBroker

public MessageBroker()
Default constructor.

Method Detail

getBundleBaseName

public String getBundleBaseName()
Gets the base name for the resource bundle.

Returns:
the ResourceBundle base name

setBundleBaseName

public void setBundleBaseName(String baseName)
Sets the base name for the resource bundle.

Parameters:
baseName - the resource bundle base name

getResourceKeyPrefix

public String getResourceKeyPrefix()
Gets the resource key prefix.

Returns:
the resource key prefix

addMessage

public void addMessage(FacesMessage message)
Adds a message to the Faces context.

Parameters:
message - the message to add

addErrorMessage

public void addErrorMessage(String resourceKey)
Adds an error message to the Faces context.

Parameters:
resourceKey - the resource key for the message

addErrorMessage

public void addErrorMessage(String resourceKey,
                            Object[] parameters)
Adds an error message message to the Faces context.

Parameters:
resourceKey - the resource key for the message
parameters - optional formating parameters

addErrorMessage

public void addErrorMessage(Throwable t)
Adds an error message to the Faces context based upon a thrown exception.

The full class name (including path) of the exception is used a key to look up an associated message within the resource bundle. If no associated resource is found, the exception's toString method is used to generate the message.

Parameters:
t - the thrown exception

addSuccessMessage

public void addSuccessMessage(String resourceKey)
Adds a success message to the Faces context.

Parameters:
resourceKey - the resource key for the message

addSuccessMessage

public void addSuccessMessage(String resourceKey,
                              Object[] parameters)
Adds a success message to the Faces context.

Parameters:
resourceKey - the resource key for the message
parameters - optional formating parameters

getMessage

public FacesMessage getMessage(String resourceKey)
Gets a message from a resource bundle.

Parameters:
resourceKey - the resource key for the message
Returns:
the message

getMessage

public FacesMessage getMessage(String resourceKey,
                               Object[] parameters)
Gets a message from a resource bundle.

Parameters:
resourceKey - the resource key for the message
parameters - optional formating parameters
Returns:
the message

getLocale

public Locale getLocale()
Gets locale. If locale is null, it will attempt to get it from the jsf viewRoot

Returns:
locale

retrieveMessage

public String retrieveMessage(String resourceKey)
Retrieves a message from a resource bundle.

Parameters:
resourceKey - the resource key for the message
Returns:
the message

retrieveMessage

public String retrieveMessage(String resourceKey,
                              Object[] parameters)
Retrieves a message from a resource bundle.

Parameters:
resourceKey - the resource key for the message
parameters - optional formating parameters
Returns:
the message

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.