/**
* Resolve the specified message into a concrete message String.
* The returned message String should be unescaped.
*/
protected String resolveMessage() throws JspException, NoSuchMessageException {
MessageSource messageSource = getMessageSource();
if (messageSource == null) {
throw new JspTagException("No corresponding MessageSource found");
}
// Evaluate the specified MessageSourceResolvable, if any.
MessageSourceResolvable resolvedMessage = null;
if (this.message instanceof MessageSourceResolvable) {
resolvedMessage = (MessageSourceResolvable) this.message;
}
else if (this.message != null) {
String expr = this.message.toString();
resolvedMessage = (MessageSourceResolvable)
ExpressionEvaluationUtils.evaluate("message", expr, MessageSourceResolvable.class, pageContext);
}
if (resolvedMessage != null) {
// We have a given MessageSourceResolvable.
return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale());
}
String resolvedCode = ExpressionEvaluationUtils.evaluateString("code", this.code, pageContext);
String resolvedText = ExpressionEvaluationUtils.evaluateString("text", this.text, pageContext);
if (resolvedCode != null || resolvedText != null) {
// We have a code or default text that we need to resolve.
Object[] argumentsArray = resolveArguments(this.arguments);
if (resolvedText != null) {
// We have a fallback text to consider.
return messageSource.getMessage(
resolvedCode, argumentsArray, resolvedText, getRequestContext().getLocale());
}
else {
// We have no fallback text to consider.
return messageSource.getMessage(
resolvedCode, argumentsArray, getRequestContext().getLocale());
}
}
// All we have is a specified literal text.