jp.terasoluna.fw.web.struts.action
Class PropertyMessageResourcesEx
java.lang.Object
org.apache.struts.util.MessageResources
org.apache.struts.util.PropertyMessageResources
jp.terasoluna.fw.web.struts.action.PropertyMessageResourcesEx
- All Implemented Interfaces:
- java.io.Serializable
public class PropertyMessageResourcesEx
- extends org.apache.struts.util.PropertyMessageResources
Property file message resources which enables the display of system (framework) message resources and the message resources
which are common to all modules.
As per the Struts specifications, message resource definition is independent for each module.
Hence, the message resources common to all modules cannot be uniquely defined.
TERASOLUNA provides the method of using the application messages and system messages common to all modules
This class extends PropertyMessageResources of Struts and enables to use not only the message resource
definition file of each module but also application messages and system messages.
For the contents defined in the application message resources and system message resources,
refer to GlobalMessageResources.
How to use
To use this class, specify the following in the <message-resource> element of
struts-config.xml
- Specify property file name (.properties is not required) as the parameter attribute
- Specify PropertyMessageResourcesExFactory as the factory attribute
Following is the configuration example of struts-config.xml.
<struts-config>
...
<message-resources parameter="MessageResources"
factory="jp.terasoluna.fw.web.struts.action.PropertyMessageResourcesExFactory"
/>
...
</struts-config>
Constraints
- System message reources does not support internationalization.
- Application message resources does not support internationalization.
The priority sequence for fetching the message resources with the same key, is as follows.
- Message resources of message resource definition file
- Message resources of the application resource definition file(application-messages.properties)
- Message resources of system message resource definition file(system-messages.properties)
- See Also:
PropertyMessageResourcesExFactory
,
DBMessageResources
,
GlobalMessageResources
,
Serialized Form
Fields inherited from class org.apache.struts.util.PropertyMessageResources |
locales, log, messages |
Fields inherited from class org.apache.struts.util.MessageResources |
config, defaultFactory, defaultLocale, factory, formats, returnNull |
Constructor Summary |
PropertyMessageResourcesEx(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config)
Constructor. |
PropertyMessageResourcesEx(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config,
boolean returnNull)
Constructor. |
Method Summary |
java.lang.String |
getMessage(java.util.Locale locale,
java.lang.String key)
Fetches the messages.
The priority sequence for fetching the messages, is as follows:
1)Message resources defined in each module,
2)Messages in the Application message resource file
and
3)Messages in System message resource file
|
Methods inherited from class org.apache.struts.util.PropertyMessageResources |
loadLocale |
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 |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- Serial version ID
- See Also:
- Constant Field Values
PropertyMessageResourcesEx
public PropertyMessageResourcesEx(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config)
- Constructor.
- Parameters:
factory
- Factory object of this classconfig
- Message resource file name
PropertyMessageResourcesEx
public PropertyMessageResourcesEx(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config,
boolean returnNull)
- Constructor.
- Parameters:
factory
- Factory object of this classconfig
- Message resource file namereturnNull
- Check if it returns null when message resource key is not registered.
getMessage
public java.lang.String getMessage(java.util.Locale locale,
java.lang.String key)
- Fetches message.
the priority sequence for fetching the messages, is as follows.
- Message resources defined in each module,
Messages in the file
- Application messages
- System messages
- Overrides:
getMessage
in class org.apache.struts.util.PropertyMessageResources
- Parameters:
locale
- Locale fetched from the requestkey
- Message resource key
- Returns:
- Message