|
||||||||||
Previous class Next class | Frames No frames | |||||||||
Overview: Nested | Field | Constructor | Method | Details: Field | Constructor | Method |
java.lang.Objectorg.apache.struts.util.MessageResources
jp.terasoluna.fw.web.struts.action.DBMessageResources
public class DBMessageResources
Message resource function is a function that fetches message for a specific
key such as error message displayed in JSP.
Using this class enables to use not only message resource definition file (message resource of property file format
which is generally used in Struts) but also message resource fetched from DB by referring to DB at the time of class load.
Message resources set in DB are shared across all modules.However, message resources of message resource definition file are independent for each module of Struts. Following sample explains how the message resource function behaves when this class is used.
For example, there are multiple modules such as module A and module B.
Message resource settings (message resource definition file)of each module
contains the following specifications.
Module name | Message key | Message statement | Message registration destination |
Module A | message.propMessageResource | "moduleA" | Message resource definition file |
message.dbMessageResource | "DB" | DB | |
Module B | message.propMessageResource | "moduleB" | Message resource definition file |
message.subMessageResource | "subModule" | Message resource definition file |
message.propMessageResource
in message resource definition file
which is defined in module A
message.dbMessageResource
which is the message resource in DB
message.propMessageResource
in message resource definition file
which is defined in module Bmessage.subMessageResource
in message resource definition file
which is defined in module Bmessage.dbMessageResource
which is the message
resource in DB of module Amessage.propMessageResource
. However, the message that could be fetched in
each module is
message.dbMessageResource
for module A as well as
module B.module.subMessageResource
from module A.)
GlobalMessageResources
.
.properties
) extension removed.DBMessageResourcesFactory
MessageResourcesDAOImpl
,
refer to Javadoc of same class.
<Message key>=<Message statement>
errors.requiredArray={1} of item number {0} is mandatory.
errors.alphaNumericStringArray={1} of item number {0} should be half-width alphanumeric character.
GlobalMessageResources
,
DBMessageResourcesFactory
,
MessageResourcesDAO
,
MessageResourcesDAOImpl
,
Serialized formField Summary | |
---|---|
private static java.lang.String |
DB_MESSAGE_RESOURCES_ERROR
Error code that indicates failure of message retrieval. |
private static java.lang.String |
DB_MESSAGE_RESOURCES_ERROR_INIT
Error code that indicates failure of message resource initialization. |
private static java.util.Map |
dbMessages
Map that stores message key and message statement fetched from DB. |
private static org.apache.commons.logging.Log |
log
Log class. |
private java.util.Map<java.lang.String,java.lang.String> |
messages
Map that stores message key and message statement fetched from message resource definition file. |
static java.lang.String |
MESSAGES_DAO
Key that is used while fetching DAO in system settings property file (system.properties). |
static java.lang.String |
MESSAGES_SQL
Key that is used while fetching SQL in system setting property file(system.properties). |
private static long |
serialVersionUID
Serial version ID |
Field inherited from class org.apache.struts.util.MessageResources |
---|
config, defaultFactory, defaultLocale, factory, formats, returnNull |
Constructor Summary | |
---|---|
DBMessageResources(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config)
Generate DBMessageResources by the specified parameter. |
|
DBMessageResources(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config,
boolean returnNull)
Generate DBMessageResources by the specified parameter. |
Method Summary | |
---|---|
protected static void |
dbInit()
Fetch the pair of message key and message statement in DB. |
java.lang.String |
getMessage(java.util.Locale locale,
java.lang.String key)
Fetch the message statement based on the specified key. |
java.lang.String |
getMessage(java.lang.String key)
Fetch the message statement based on the specified key. |
protected void |
propertyInit(java.lang.String propertyFile)
Fetch the pair of message key and message statement from the message resource definition file. |
Method inherited from class org.apache.struts.util.MessageResources |
---|
escape, getConfig, getFactory, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageResources, getReturnNull, isEscape, isPresent, isPresent, localeKey, log, log, messageKey, messageKey, setEscape, setReturnNull |
Method inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Details |
---|
private static final long serialVersionUID
public static final java.lang.String MESSAGES_DAO
public static final java.lang.String MESSAGES_SQL
private static final java.lang.String DB_MESSAGE_RESOURCES_ERROR
private static final java.lang.String DB_MESSAGE_RESOURCES_ERROR_INIT
private static org.apache.commons.logging.Log log
private static java.util.Map dbMessages
private java.util.Map<java.lang.String,java.lang.String> messages
Constructor Details |
---|
public DBMessageResources(org.apache.struts.util.MessageResourcesFactory factory, java.lang.String config)
factory
- Message resource factoryconfig
- Message resource definition file namepublic DBMessageResources(org.apache.struts.util.MessageResourcesFactory factory, java.lang.String config, boolean returnNull)
factory
- Message resource factoryconfig
- Message resource definition file namereturnNull
- When returnNull
of org.apache.struts.util.MessageResources
is set to
false
and the message corresponding to the key does not exist, return the message
in ???Locale.key??? format.
Method Details |
---|
protected static void dbInit()
protected void propertyInit(java.lang.String propertyFile)
propertyFile
- Message resource definition file namepublic java.lang.String getMessage(java.util.Locale locale, java.lang.String key)
When the initialization process is not performed for all the message resources or when unable to fetch the value that corresponds to the message key from any of the definition, based on the value of "returnNull" at the time of generation, the value returned is either null or in the struts format(???Locale.key???).
The locale specified here is not considered. In short, performs the operation same as getMessage(key).
getMessage
in class org.apache.struts.util.MessageResources
locale
- Message locale. It is not taken into consideration. key
- Message key
public java.lang.String getMessage(java.lang.String key)
getMessage
in class org.apache.struts.util.MessageResources
key
- Message key
|
||||||||||
Previous class Next class | Frames No frames | |||||||||
Overview: Nested | Field | Constructor | Method | Details: Field | Constructor | Method |