public final class JsfMessageUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BUNDLE
Name of the application's resource bundle as defined as a var in faces-Config.xml.
|
static String |
DETAIL_SUFFIX
The suffix that is added to the bundle key to get the detail message.
|
Modifier and Type | Method and Description |
---|---|
static void |
addMessage(javax.faces.application.FacesMessage message)
Adds the supplied message as a generic (not for a particular component) message.
|
static void |
addMessage(javax.faces.application.FacesMessage message,
javax.faces.application.FacesMessage.Severity severity)
Adds the supplied message with the supplied severity, as a generic (not for a particular component) message.
|
static void |
addMessage(String clientId,
javax.faces.application.FacesMessage message)
Adds the supplied message, as a specific message, for a component with the supplied clientId.
|
static void |
addMessage(String clientId,
javax.faces.application.FacesMessage message,
javax.faces.application.FacesMessage.Severity severity)
Adds the supplied message with the supplied severity, as a specific message, for a component with the supplied clientId.
|
static javax.faces.application.FacesMessage |
createErrorMessageFromLocalizedException(AbstractLocalizedException localizedException)
Creates a faces error message from the supplied localizedException.
|
static javax.faces.application.FacesMessage |
createErrorMessageFromLocalizedRuntimeException(AbstractLocalizedRuntimeException localizedRuntimeException)
Creates a faces error message from the supplied localizedRuntimeException.
|
static String |
createJavaScriptAlert(javax.faces.application.FacesMessage message)
Creates JavaScript code to create an alert (dialog box) that contains the supplied message.
|
static String |
getCssClassForSeverity(javax.faces.application.FacesMessage.Severity severity)
Gets the css class that corresponds to the supplied severity.
|
static javax.faces.application.FacesMessage |
getErrorMessage(String bundleVarName,
String bundleKey,
Object... messageArguments)
Gets an error message from the ResourceBundle with the supplied bundleVarName and the supplied bundleKey.
|
static String |
getImageForSeverity(javax.faces.application.FacesMessage.Severity severity)
Gets the image that belongs to a message of the supplied severity.
|
static javax.faces.application.FacesMessage |
getJosefErrorMessage(String bundleKey,
Object... messageArguments)
Gets an error message from the standard Josef ResourceBundle.
|
static javax.faces.application.FacesMessage |
getJosefMessage(String bundleKey,
Object... messageArguments)
Gets a message from the standard Josef ResourceBundle.
|
static String |
getJosefStringMessage(String bundleKey,
Object... messageArguments)
Gets a String message from Josef's Resource bundle with the supplied bundleKey.
|
static String |
getJsfStandardStringMessage(String bundleKey,
Object... messageArguments)
Gets a String message from the standard JSF Resource bundle, with the supplied bundleKey.
|
static javax.faces.application.FacesMessage |
getMessage(String bundleVarName,
String bundleKey,
Object... messageArguments)
Gets a message from the ResourceBundle with the supplied bundleVarName and the supplied bundleKey.
|
static javax.faces.application.FacesMessage |
getMessage(Throwable throwable)
Gets a message from the supplied throwable.
|
static javax.faces.application.FacesMessage |
getMostSevereMessage(Collection<javax.faces.application.FacesMessage> messages)
Gets the most severe message from the supplied collection of messages.
|
static String |
getOptionalStringMessage(String bundleVarName,
String bundleKey,
String defaultValue,
Object... messageArguments)
Gets an optional String message from the ResourceBundle with the supplied bundleVarName and the supplied bundleKey.
|
static String |
getRequiredStringMessage(String bundleVarName,
String bundleKey,
Object... messageArguments)
Gets a String message from the ResourceBundle with the supplied bundleVarName and the supplied bundleKey which must be
present.
|
static ResourceBundle |
getResourceBundle(String bundleVarName)
Gets the ResourceBundle with the supplied bundleVarName.
|
static String |
getStringMessage(String bundleVarName,
String bundleKey,
Object... messageArguments)
Gets a String message from the Resource bundle with the supplied bundleVarName and the supplied bundleKey.
|
static boolean |
hasErrorOccurred()
Determines whether an error has occurred.
|
public static final String BUNDLE
public static final String DETAIL_SUFFIX
public static void addMessage(javax.faces.application.FacesMessage message, javax.faces.application.FacesMessage.Severity severity)
message
- The message to add.severity
- The severity of the messages.NullPointerException
- When the supplied message is null.public static void addMessage(javax.faces.application.FacesMessage message)
message
- The message to add.NullPointerException
- When the supplied message is null.public static void addMessage(String clientId, javax.faces.application.FacesMessage message, javax.faces.application.FacesMessage.Severity severity)
clientId
- Client ID of the component for which the message should be added.message
- The message to add.severity
- The severity of the messages.IllegalArgumentException
- When the supplied clientId is empty.NullPointerException
- When either the supplied clientId or message is null.public static void addMessage(String clientId, javax.faces.application.FacesMessage message)
clientId
- Client ID of the component for which the message should be added.message
- The message to add.IllegalArgumentException
- When the supplied clientId is empty.NullPointerException
- When either the supplied clientId or message is null.public static ResourceBundle getResourceBundle(String bundleVarName)
bundleVarName
- Name of the ResourceBundle as configured in faces-config.xml.javax.faces.FacesException
- When the ResourceBundle has been configured but is not resolvable.MissingResourceException
- When no ResourceBundle with the supplied bundleVarName exists.
Level.SEVERE
is logged.NullPointerException
- When the supplied bundleVarName is null.IllegalArgumentException
- When the supplied bundleVarName is empty.public static javax.faces.application.FacesMessage getJosefMessage(String bundleKey, Object... messageArguments)
bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.MissingResourceException
is thrown! This event is logged as a
Level.WARNING
javax.faces.FacesException
- When the josefBundle has been configured but is not resolvable.NullPointerException
- When the supplied bundleKey is null.IllegalArgumentException
- When the supplied bundleKey is empty or when the message could not be formatted.getMessage(String, String, Object...)
public static javax.faces.application.FacesMessage getJosefErrorMessage(String bundleKey, Object... messageArguments)
bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.MissingResourceException
is thrown! This event is logged as a
Level.WARNING
.javax.faces.FacesException
- When the josefBundle has been configured but is not resolvable.NullPointerException
- When the supplied bundleKey is null.IllegalArgumentException
- When the supplied bundleKey is empty or when the message could not be formatted.getMessage(String, String, Object...)
public static String getJsfStandardStringMessage(String bundleKey, Object... messageArguments)
bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.MissingResourceException
- When the supplied bundleKey does not exist.NullPointerException
- When the supplied bundleKey is null.IllegalArgumentException
- When either the supplied bundleKey is empty or when the message could not be formatted.public static javax.faces.application.FacesMessage getMessage(String bundleVarName, String bundleKey, Object... messageArguments)
bundleVarName
- The variable name of the ResourceBundle as configured in faces-config.xml.bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.
MissingResourceException
is thrown! This event is logged as a
Level.WARNING
javax.faces.FacesException
- When a ResourceBundle with the supplied bundleVarName has been configured but is not
resolvable.NullPointerException
- When either the supplied bundleVarName or bundleKey is null.IllegalArgumentException
- When either the supplied bundleVarName or bundleKey is empty or when the message could
not be formatted.public static javax.faces.application.FacesMessage getErrorMessage(String bundleVarName, String bundleKey, Object... messageArguments)
bundleVarName
- The variable name of the ResourceBundle as configured in faces-config.xml.bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.
MissingResourceException
is thrown! This event is logged as a
Level.WARNING
javax.faces.FacesException
- When a ResourceBundle with the supplied bundleVarName has been configured but is not
resolvable.NullPointerException
- When either the supplied bundleVarName or bundleKey is null.IllegalArgumentException
- When either the supplied bundleVarName or bundleKey is empty or when the message could
not be formatted.getMessage(String, String, Object...)
public static String getRequiredStringMessage(String bundleVarName, String bundleKey, Object... messageArguments)
MissingResourceException
is thrown! This event is logged as a
Level.WARNING
bundleVarName
- The variable name of the ResourceBundle as configured in faces-config.xml.bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.javax.faces.FacesException
- When a ResourceBundle with the supplied bundleVarName has been configured but is not
resolvable.NullPointerException
- When either the supplied bundleVarName or bundleKey is null.IllegalArgumentException
- When either the supplied bundleVarName or bundleKey is empty or when the message could
not be formatted.public static String getOptionalStringMessage(String bundleVarName, String bundleKey, String defaultValue, Object... messageArguments)
bundleVarName
- The variable name of the ResourceBundle as configured in faces-config.xml.bundleKey
- The key to the ResourceBundle.defaultValue
- The value to return when the supplied bundleKey is not present.messageArguments
- The optional message arguments.javax.faces.FacesException
- When a ResourceBundle with the supplied bundleVarName has been configured but is not
resolvable.NullPointerException
- When either the supplied bundleVarName or bundleKey is null.IllegalArgumentException
- When either the supplied bundleVarName or bundleKey is empty or when the message could
not be formatted.public static String getJosefStringMessage(String bundleKey, Object... messageArguments)
bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.javax.faces.FacesException
- When Josef's ResourceBundle has been configured but is not resolvable.MissingResourceException
- When Josef's resource bundle is missing or when the supplied bundleKey does not exist.NullPointerException
- When the supplied bundleKey is null.IllegalArgumentException
- When either the supplied bundleKey is empty or when the message could not be formatted.public static String getStringMessage(String bundleVarName, String bundleKey, Object... messageArguments)
bundleVarName
- The variable name of the ResourceBundle as configured in faces-config.xml.bundleKey
- The key to the ResourceBundle.messageArguments
- The optional message arguments.javax.faces.FacesException
- When a ResourceBundle with the supplied bundleVarName has been configured but is not
resolvable.MissingResourceException
- When either the supplied bundleVarName does not correspond with an existing
ResourceBundle or when the supplied bundleKey does not exist.NullPointerException
- When either the supplied bundleVarName or bundleKey is null.IllegalArgumentException
- When either the supplied bundleVarName or bundleKey is empty or when the message could
not be formatted.public static javax.faces.application.FacesMessage getMessage(Throwable throwable)
throwable
- The throwable to get the message from.NullPointerException
- When the supplied throwable is null.public static javax.faces.application.FacesMessage createErrorMessageFromLocalizedException(AbstractLocalizedException localizedException)
localizedException
- The localized exception to get the message from.NullPointerException
- When the supplied localizedException is null.public static javax.faces.application.FacesMessage createErrorMessageFromLocalizedRuntimeException(AbstractLocalizedRuntimeException localizedRuntimeException)
localizedRuntimeException
- The localized runtime exception to get the message from.NullPointerException
- When the supplied localizedRuntimeException is null.public static javax.faces.application.FacesMessage getMostSevereMessage(Collection<javax.faces.application.FacesMessage> messages)
messages
- A possibly null or empty messages collection.public static boolean hasErrorOccurred()
FacesMessage.SEVERITY_ERROR
or
FacesMessage.SEVERITY_FATAL
exists.public static String createJavaScriptAlert(javax.faces.application.FacesMessage message)
message
- The message to show as an alert in JavaScript.public static String getImageForSeverity(javax.faces.application.FacesMessage.Severity severity)
severity
- The severity for which the corresponding image needs to be returned.
public static String getCssClassForSeverity(javax.faces.application.FacesMessage.Severity severity)
severity
- The severity for which the corresponding css class needs to be returned.
Copyright © 2008–2018. All rights reserved.