Package org.apache.velocity.tools.struts
Class ActionMessagesTool
- java.lang.Object
-
- org.apache.velocity.tools.struts.MessageResourcesTool
-
- org.apache.velocity.tools.struts.ActionMessagesTool
-
- Direct Known Subclasses:
ErrorsTool
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.
- Since:
- VelocityTools 1.1
- Version:
- $Id: ActionMessagesTool.java 479724 2006-11-27 18:49:37Z nbubna $
- Author:
- Gabe Sidler, Nathan Bubna
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.struts.action.ActionMessagesactionMsgsA reference to the queued action messages.protected static org.apache.commons.logging.LogLOG-
Fields inherited from class org.apache.velocity.tools.struts.MessageResourcesTool
application, locale, request, resources
-
-
Constructor Summary
Constructors Constructor Description ActionMessagesTool()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexist()Returnstrueif there are action messages queued, otherwisefalse.booleanexist(java.lang.String property)Returns true if there are action messages queued for the specified category of messages, otherwisefalse.java.util.Listget(java.lang.String property)Returns the set of localized action messages as anjava.util.Listof strings for all actionMsgs queued of the specified category ornullif no messages are queued for the specified category.java.util.Listget(java.lang.String property, java.lang.String bundle)Returns the set of localized action messages as ajava.util.Listof strings for all action messages queued of the specified category ornullif no action messages are queued for the specified category.java.util.ListgetAll()Returns the set of localized action messages as anjava.util.Listof strings for all actionMsgs queued ornullif no messages are queued.java.util.ListgetAll(java.lang.String bundle)Returns a List of all queued action messages using the specified message resource bundle.java.util.ListgetGlobal()This a convenience method and the equivalent of$messages.get($messages.globalName).java.lang.StringgetGlobalName()Returns the default "GLOBAL" category name that can be used for messages that are not associated with a particular property.intgetSize()Returns the number of action messages queued.intgetSize(java.lang.String property)Returns the number of action messages queued for a particular property.voidinit(java.lang.Object obj)Initializes this tool.-
Methods inherited from class org.apache.velocity.tools.struts.MessageResourcesTool
getResources
-
-
-
-
Method Detail
-
init
public void init(java.lang.Object obj)
Initializes this tool.- Overrides:
initin classMessageResourcesTool- Parameters:
obj- the current ViewContext- Throws:
java.lang.IllegalArgumentException- if the param is not a ViewContext
-
exist
public boolean exist()
Returns
trueif there are action messages queued, otherwisefalse.
-
exist
public boolean exist(java.lang.String property)
Returns true if there are action messages queued for the specified category of messages, otherwise
false.- Parameters:
property- the category of messages to check for
-
getSize
public int getSize()
Returns the number of action messages queued.
-
getSize
public int getSize(java.lang.String property)
Returns the number of action messages queued for a particular property.- Parameters:
property- the category of messages to check for
-
getGlobal
public 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
nullif 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.- Returns:
- a list of all messages stored under the "global" property
-
getAll
public java.util.List getAll()
Returns the set of localized action messages as anjava.util.Listof strings for all actionMsgs queued ornullif 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.
-
getAll
public java.util.List getAll(java.lang.String bundle)
Returns a List of all queued action messages using the specified message resource bundle.- Parameters:
bundle- the message resource bundle to use- See Also:
getAll()
-
get
public java.util.List get(java.lang.String property)
Returns the set of localized action messages as anjava.util.Listof strings for all actionMsgs queued of the specified category ornullif 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.- Parameters:
property- the category of actionMsgs to operate on
-
get
public java.util.List get(java.lang.String property, java.lang.String bundle)Returns the set of localized action messages as ajava.util.Listof strings for all action messages queued of the specified category ornullif 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.- Parameters:
property- the category of actionMsgs to operate onbundle- the message resource bundle to use
-
getGlobalName
public java.lang.String getGlobalName()
Returns the default "GLOBAL" category name that can be used for messages that are not associated with a particular property.
-
-