public class MessageHelper extends Object
MessageHelper
provides functions to access messages resources and to save messages in
the request as either error or success messages.Modifier and Type | Field and Description |
---|---|
static String |
CLIENT_ID_REQUEST_ATTRIBUTE
Request attribute name for storing the current client ID.
|
static String |
ERROR_MESSAGES_KEY
The request key to be used for error messages.
|
static String |
INFO_MESSAGES_KEY
The request key to be used for info messages.
|
static String |
MESSAGES_KEY
The request key to be used for messages
|
static String |
MESSAGES_TARGET
the request key to be sued for the message target.
|
static String |
WARNING_MESSAGES_KEY
The request key to be used for warnings.
|
Modifier and Type | Method and Description |
---|---|
static String |
getText(javax.servlet.http.HttpServletRequest request,
LocalizedMessage localizedMessage,
Object... arguments)
Get the localized value of the LocalizedMessage
|
static String |
getText(javax.servlet.http.HttpServletRequest request,
String msgKey)
Convenience method for getting a i18n key's value.
|
static String |
getText(javax.servlet.http.HttpServletRequest request,
String msgKey,
Object[] args)
Method for getting a i18n key's value.
|
static boolean |
hasText(javax.servlet.http.HttpServletRequest request,
String msgKey,
Object[] arguments) |
static void |
saveErrorMessage(javax.servlet.http.HttpServletRequest request,
LocalizedMessage message)
Saves a new message in the request under the key
ERROR_MESSAGES_KEY as
error message |
static void |
saveErrorMessage(javax.servlet.http.HttpServletRequest request,
String message)
Saves a new message in the request under the key
ERROR_MESSAGES_KEY as
error message |
static void |
saveErrorMessageFromKey(javax.servlet.http.HttpServletRequest request,
String messageKey)
Saves a new message in the request under the key
ERROR_MESSAGES_KEY as
error message |
static void |
saveErrorMessageFromKey(javax.servlet.http.HttpServletRequest request,
String messageKey,
Object... arguments)
Saves a new message in the request under the key
ERROR_MESSAGES_KEY as
error message |
static void |
saveMessage(javax.servlet.http.HttpServletRequest request,
LocalizedMessage message)
Saves a new message in the request under the key
MESSAGES_KEY as
success message |
static void |
saveMessage(javax.servlet.http.HttpServletRequest request,
String message)
Saves a new message in the request under the key
MESSAGES_KEY as
success message |
static void |
saveMessage(javax.servlet.http.HttpServletRequest request,
String message,
String type)
Saves a message with the specified key.
|
static void |
saveMessageFromKey(javax.servlet.http.HttpServletRequest request,
String messageKey)
Saves a new message in the request under the key
MESSAGES_KEY as
success message |
static void |
saveMessageFromKey(javax.servlet.http.HttpServletRequest request,
String messageKey,
String type)
Saves a new message in the request under the key
MESSAGES_KEY as
success message |
static void |
saveMessageFromKey(javax.servlet.http.HttpServletRequest request,
String messageKey,
String type,
Object... arguments)
Saves a new message in the request under the key
MESSAGES_KEY as
success message |
static void |
setMessageTarget(javax.servlet.http.HttpServletRequest request,
String url)
Sets the message view target.
|
public static final String MESSAGES_KEY
public static final String INFO_MESSAGES_KEY
public static final String ERROR_MESSAGES_KEY
public static final String WARNING_MESSAGES_KEY
public static final String MESSAGES_TARGET
public static final String CLIENT_ID_REQUEST_ATTRIBUTE
public static String getText(javax.servlet.http.HttpServletRequest request, LocalizedMessage localizedMessage, Object... arguments)
request
- the request to determine the localelocalizedMessage
- the message providing the transaltionarguments
- if provided overrides the arguments the LocalizedMessage was created withpublic static String getText(javax.servlet.http.HttpServletRequest request, String msgKey)
request
- the request to determine the localemsgKey
- The message keypublic static String getText(javax.servlet.http.HttpServletRequest request, String msgKey, Object[] args)
request
- the request to determine the localemsgKey
- The message keyargs
- message argumentspublic static boolean hasText(javax.servlet.http.HttpServletRequest request, String msgKey, Object[] arguments)
request
- The request.msgKey
- The message key.arguments
- Possible arguments.public static void saveErrorMessage(javax.servlet.http.HttpServletRequest request, LocalizedMessage message)
ERROR_MESSAGES_KEY
as
error messagerequest
- The request to save the messages tomessage
- the LocalizedMessage
containing the translated messagepublic static void saveErrorMessage(javax.servlet.http.HttpServletRequest request, String message)
ERROR_MESSAGES_KEY
as
error messagerequest
- The request to save the messages tomessage
- the message text to savepublic static void saveErrorMessageFromKey(javax.servlet.http.HttpServletRequest request, String messageKey)
ERROR_MESSAGES_KEY
as
error messagerequest
- The request to save the messages tomessageKey
- The key of the message.public static void saveErrorMessageFromKey(javax.servlet.http.HttpServletRequest request, String messageKey, Object... arguments)
ERROR_MESSAGES_KEY
as
error messagerequest
- The request to save the messages tomessageKey
- The key of the message.arguments
- Message arguments.public static void saveMessage(javax.servlet.http.HttpServletRequest request, LocalizedMessage message)
MESSAGES_KEY
as
success messagerequest
- The request to save the messages tomessage
- the message text to savepublic static void saveMessage(javax.servlet.http.HttpServletRequest request, String message)
MESSAGES_KEY
as
success messagerequest
- The request to save the messages tomessage
- the message text to savepublic static void saveMessage(javax.servlet.http.HttpServletRequest request, String message, String type)
request
- The request.message
- The message.type
- The message type (Error, Success, ...).public static void saveMessageFromKey(javax.servlet.http.HttpServletRequest request, String messageKey)
MESSAGES_KEY
as
success messagerequest
- The request to save the messages tomessageKey
- The key of the message.public static void saveMessageFromKey(javax.servlet.http.HttpServletRequest request, String messageKey, String type)
MESSAGES_KEY
as
success messagerequest
- The request to save the messages tomessageKey
- The key of the message.type
- The messages type.public static void saveMessageFromKey(javax.servlet.http.HttpServletRequest request, String messageKey, String type, Object... arguments)
MESSAGES_KEY
as
success messagerequest
- The request to save the messages tomessageKey
- The key of the message.type
- The messages type.arguments
- Arguments.public static void setMessageTarget(javax.servlet.http.HttpServletRequest request, String url)
request
- the requesturl
- the urlCopyright © 2019 Communote team. All rights reserved.