public class ActionMessagesTool extends MessageResourcesTool
View tool to work with the Struts action messages.
Template example(s):
#if( $messages.exist() )
#foreach( $e in $messages.all )
$e <br>
#end
#end
Toolbox configuration:
<tool>
<key>messages</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.ActionMessagesTool</class>
</tool>
This tool should only be used in the request scope.
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.struts.action.ActionMessages |
actionMsgs
A reference to the queued action messages.
|
protected static org.apache.commons.logging.Log |
LOG |
application, locale, request, resources| Constructor and Description |
|---|
ActionMessagesTool()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
exist()
Returns
true if there are action messages queued,
otherwise false. |
boolean |
exist(java.lang.String property)
Returns true if there are action messages queued for the specified
category of messages, otherwise
false. |
java.util.List |
get(java.lang.String property)
Returns the set of localized action messages as an
java.util.List of strings for all actionMsgs
queued of the specified category or null
if no messages are queued for the specified category. |
java.util.List |
get(java.lang.String property,
java.lang.String bundle)
Returns the set of localized action messages as a
java.util.List of strings for all action messages
queued of the specified category or null
if no action messages are queued for the specified category. |
java.util.List |
getAll()
Returns the set of localized action messages as an
java.util.List of strings for all actionMsgs
queued or null if no messages are queued. |
java.util.List |
getAll(java.lang.String bundle)
Returns a List of all queued action messages using
the specified message resource bundle.
|
java.util.List |
getGlobal()
This a convenience method and the equivalent of
$messages.get($messages.globalName). |
java.lang.String |
getGlobalName()
Returns the default "GLOBAL" category name that can be used for
messages that are not associated with a particular property.
|
int |
getSize()
Returns the number of action messages queued.
|
int |
getSize(java.lang.String property)
Returns the number of action messages queued for a particular property.
|
void |
init(java.lang.Object obj)
Initializes this tool.
|
getResourcesprotected static final org.apache.commons.logging.Log LOG
protected org.apache.struts.action.ActionMessages actionMsgs
public ActionMessagesTool()
public void init(java.lang.Object obj)
init in class MessageResourcesToolobj - the current ViewContextjava.lang.IllegalArgumentException - if the param is not a ViewContextpublic boolean exist()
Returns true if there are action messages queued,
otherwise false.
public boolean exist(java.lang.String property)
Returns true if there are action messages queued for the specified
category of messages, otherwise false.
property - the category of messages to check forpublic int getSize()
public int getSize(java.lang.String property)
property - the category of messages to check forpublic java.util.List getGlobal()
This a convenience method and the equivalent of
$messages.get($messages.globalName).
Returns the set of localized action messages as an
list of strings for all action messages queued of the
global category or null if no messages
are queued for the specified category. If the message
resources don't contain an action message for a
particular message key, the key itself is used.
public java.util.List getAll()
java.util.List of strings for all actionMsgs
queued or null if no messages are queued.
If the message resources don't contain a message for a
particular key, the key itself is used as the message.public java.util.List getAll(java.lang.String bundle)
bundle - the message resource bundle to usegetAll()public java.util.List get(java.lang.String property)
java.util.List of strings for all actionMsgs
queued of the specified category or null
if no messages are queued for the specified category. If the
message resources don't contain a message for a particular
key, the key itself is used as the message.property - the category of actionMsgs to operate onpublic java.util.List get(java.lang.String property,
java.lang.String bundle)
java.util.List of strings for all action messages
queued of the specified category or null
if no action messages are queued for the specified category. If the
message resources don't contain an action message for a particular
action key, the key itself is used as action message.property - the category of actionMsgs to operate onbundle - the message resource bundle to usepublic java.lang.String getGlobalName()
Copyright (c) 2003-2007 Apache Software Foundation