Class AppMessageResources
- All Implemented Interfaces:
Serializable
PropertyMessageResources
class which
wraps a second PropertyMessageResources
object holding custom
application messages.
Messages that come distributed with the application are stored in the
application.properties
files under the
"/WEB-INF/classes/resources" directory. These files may be overwritten with a
future upgrade, if new messages need to be added to the files. In order to
make use of the Struts MessageResources
facility for custom
messages, this class automatically creates a second
AppMessageResources
object from a file named
application-custom.properties
in the same directory as the
distributed application.properties
file. Custom messages can
safely be placed in these application-custom.properties
files
because they will not be overwritten during an upgrade.
This class overrides a constructor method, to create the second, custom
AppMessageResources
object from the
application-custom.properties
file. It also overrides the
getMessage
method to look for a message first in the custom
object before attempting to find it in the original
AppMessageResources
object. This allows users to override the
default messages with custom ones.
- Author:
- David Tobey
- See Also:
-
Field Summary
Modifier and TypeFieldDescription(package private) AppMessageResources
(package private) boolean
(package private) static org.apache.commons.logging.Log
private static final long
Fields inherited from class org.apache.struts.util.PropertyMessageResources
locales, messages
Fields inherited from class org.apache.struts.util.MessageResources
config, defaultFactory, defaultLocale, factory, formats, returnNull
-
Constructor Summary
ConstructorDescriptionAppMessageResources
(org.apache.struts.util.MessageResourcesFactory factory, String config, boolean returnNull, boolean isChild) -
Method Summary
Modifier and TypeMethodDescriptiongetMessage
(Locale locale, String key) messageKeyPublic
(String locale, String key) void
setCustomMessageResources
(AppMessageResources customMessageResources) Methods inherited from class org.apache.struts.util.PropertyMessageResources
loadLocale, setMode
Methods inherited from class org.apache.struts.util.MessageResources
escape, getConfig, getFactory, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageResources, getReturnNull, isEscape, isPresent, isPresent, localeKey, log, log, messageKey, messageKey, setEscape, setReturnNull
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
log
static org.apache.commons.logging.Log log -
isChild
boolean isChild -
customMessageResources
AppMessageResources customMessageResources
-
-
Constructor Details
-
AppMessageResources
public AppMessageResources(org.apache.struts.util.MessageResourcesFactory factory, String config, boolean returnNull, boolean isChild)
-
-
Method Details
-
getCustomMessageResources
-
setCustomMessageResources
-
getMessage
- Overrides:
getMessage
in classorg.apache.struts.util.PropertyMessageResources
-
getMessages
-
getLocales
-
getFormats
-
messageKeyPublic
-