Helper class for easy access to messages from a MessageSource,
providing various overloaded getMessage methods.
Available from ApplicationObjectSupport, but also reusable
as a standalone helper to delegate to in application objects.
| Method from org.springframework.context.support.MessageSourceAccessor Detail: |
protected Locale getDefaultLocale() {
return (this.defaultLocale != null ? this.defaultLocale : LocaleContextHolder.getLocale());
}
Return the default locale to use if no explicit locale has been given.
The default implementation returns the default locale passed into the
corresponding constructor, or LocaleContextHolder's locale as fallback.
Can be overridden in subclasses. |
public String getMessage(String code) throws NoSuchMessageException {
return this.messageSource.getMessage(code, null, getDefaultLocale());
}
Retrieve the message for the given code and the default Locale. |
public String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException {
return this.messageSource.getMessage(resolvable, getDefaultLocale());
}
Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance)
in the default Locale. |
public String getMessage(String code,
String defaultMessage) {
return this.messageSource.getMessage(code, null, defaultMessage, getDefaultLocale());
}
Retrieve the message for the given code and the default Locale. |
public String getMessage(String code,
Locale locale) throws NoSuchMessageException {
return this.messageSource.getMessage(code, null, locale);
}
Retrieve the message for the given code and the given Locale. |
public String getMessage(String code,
Object[] args) throws NoSuchMessageException {
return this.messageSource.getMessage(code, args, getDefaultLocale());
}
Retrieve the message for the given code and the default Locale. |
public String getMessage(MessageSourceResolvable resolvable,
Locale locale) throws NoSuchMessageException {
return this.messageSource.getMessage(resolvable, locale);
}
Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance)
in the given Locale. |
public String getMessage(String code,
String defaultMessage,
Locale locale) {
return this.messageSource.getMessage(code, null, defaultMessage, locale);
}
Retrieve the message for the given code and the given Locale. |
public String getMessage(String code,
Object[] args,
String defaultMessage) {
return this.messageSource.getMessage(code, args, defaultMessage, getDefaultLocale());
}
Retrieve the message for the given code and the default Locale. |
public String getMessage(String code,
Object[] args,
Locale locale) throws NoSuchMessageException {
return this.messageSource.getMessage(code, args, locale);
}
Retrieve the message for the given code and the given Locale. |
public String getMessage(String code,
Object[] args,
String defaultMessage,
Locale locale) {
return this.messageSource.getMessage(code, args, defaultMessage, locale);
}
Retrieve the message for the given code and the given Locale. |