<html> | |
<head> | |
<title>VelocityStruts - ActionMessagesTool</title> | |
<meta name="author" value="Marino Jonsson"/> | |
<meta name="email" value="marino@apache.org" /> | |
</head> | |
<body bgcolor="#ffffff" text="#000000" link="#525D76" | |
alink="#525D76" vlink="#525D76"> | |
<table border="0" width="100%" cellspacing="4"> | |
<tr><td colspan="2"> | |
<a href="http://jakarta.apache.org/"> | |
<img src="http://jakarta.apache.org/images/jakarta-logo.gif" | |
align="left" alt="The Jakarta Project" border="0"/> | |
</a> | |
<a href="index.html"> | |
<img src="../images/velocitystruts.png" align="right" alt="< Velocity Tools - Struts >" border="0"/> | |
</a> | |
</td></tr> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<tr> | |
<td width="20%" valign="top" nowrap="true"> | |
<p><strong><a href="../">Velocity Tools</a></strong></p> | |
<p> | |
<strong>VelocityStruts</strong> | |
</p> | |
<ul> | |
<li><a href="index.html">Overview</a></li> | |
<li><a href="index.html#Benefits">Benefits</a></li> | |
<li><a href="../index.html#Download">Download</a></li> | |
<li><a href="userguide.html">User Guide</a></li> | |
<li><a href="userguide.html#Installation">Installation</a></li> | |
<li><a href="../index.html#Example Applications">Examples</a></li> | |
<li><a href="../javadoc/index.html">Javadoc</a></li> | |
</ul> | |
<p> | |
<a href="StrutsTools.html"><strong>VelocityStruts Tools</strong></a> | |
</p> | |
<ul> | |
<li><a href="ActionMessagesTool.html">ActionMessagesTool</a></li> | |
<li><a href="ErrorsTool.html">ErrorsTool</a></li> | |
<li><a href="FormTool.html">FormTool</a></li> | |
<li><a href="MessageTool.html">MessageTool</a></li> | |
<li><a href="StrutsLinkTool.html">StrutsLinkTool</a></li> | |
<li><a href="SecureLinkTool.html">SecureLinkTool</a></li> | |
<li><a href="TilesTool.html">TilesTool</a></li> | |
<li><a href="ValidatorTool.html">ValidatorTool</a></li> | |
</ul> | |
<p> | |
<strong>Other Subprojects</strong> | |
</p> | |
<ul> | |
<li><a href="../generic/">GenericTools</a></li> | |
<li><a href="../view/">VelocityView</a></li> | |
</ul> | |
<p> | |
</p> | |
</td> | |
<!-- RIGHT SIDE MAIN BODY --> | |
<td colspan="1" valign="top" align="left"> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="ActionMessagesTool Reference Documentation"> | |
<strong>ActionMessagesTool Reference Documentation</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
This tool deals with Struts action messages. A few important aspects about action | |
messages are:</p> | |
<ul> | |
<li>Action message strings are looked up in the message resources. Support | |
for internationalized messages is provided.</li> | |
<li>Action messages can have up to five replacement parameters.</li> | |
<li>Actions have an attribute <code>property</code> that describes the category of | |
message. This allows the view designer to place action messages precisely where they are | |
wanted. Several methods of this tool provide a parameter | |
<code>property</code> that allows to select a specific category of messages to operate | |
on. Without the <code>property</code> parameter, methods operate on all action messages.</li> | |
</ul> | |
<p>See the Struts User's Guide, section | |
<a href="http://struts.apache.org/struts-doc-1.2.7/userGuide/building_view.html">Building View Components</a> | |
for more information on this topic.</p> | |
<table cellpadding="0" cellspacing="0"> | |
<tr><td colspan="2"><strong>Class</strong></td></tr> | |
<tr><td> </td><td>org.apache.velocity.tools.struts.ActionMessagesTool</td></tr> | |
<tr><td colspan="2"><strong>Name</strong></td></tr> | |
<tr><td> </td><td>$messages (this is the recommended name of the tool in | |
the Velocity context)</td></tr> | |
<tr><td colspan="2"><strong>Toolbox Configuration Example</strong></td></tr> | |
<tr><td> </td><td><pre><tool> | |
<key>messages</key> | |
<scope>request</scope> | |
<class>org.apache.velocity.tools.struts.ActionMessagesTool</class> | |
</tool></pre></td></tr> | |
<tr><td colspan="2"><strong>Author(s)</strong></td></tr> | |
<tr><td> </td><td><a href="mailto:sidler@teamup.com">Gabriel Sidler</a><br><a href="mailto:nathan@esha.com">Nathan Bubna</a><br></td></tr> | |
</table> | |
<dl> | |
<dt><strong>Method Overview</strong></dt> | |
<dd> | |
<table cellpadding="2" cellspacing="2" border="0"> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#exist()">exist()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns <code>true</code> if there are action messages queued, | |
otherwise <code>false</code>. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getSize()">getSize()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns the number of action messages queued. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getGlobal()">getGlobal()</a></td> | |
<td bgcolor="EEEEEE"> | |
This a convenience method and the equivalent of | |
<code>$messages.get($messages.globalName)</code> | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#getAll()">getAll()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns a list of localized action messages for all action messages queued. | |
</td> | |
</tr> | |
<tr> | |
<td bgcolor="EEEEEE" nowrap> | |
<a href="#get()">get()</a></td> | |
<td bgcolor="EEEEEE"> | |
Returns a list of localized action messages for a particular category | |
of action messages. | |
</td> | |
</tr> | |
</table> | |
</dd> | |
</dl> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="exist()"> | |
<strong>exist()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns <code>true</code> if there are action messages queued, | |
otherwise <code>false</code>. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
boolean exist() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
boolean exist(String property) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>property</dt> | |
<dd> | |
<parameter name="property"> | |
The category of messages to check for. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
<code>true</code> if there are action messages queued. <code>false</code> otherwise. | |
</returns> | |
</dd> | |
</dl> | |
<p>Calling <code>exist()</code> without the <code>property</code> parameter checks for action messages of | |
any category. The <code>property</code> parameter can be used to limit the check to | |
action messages of a specific category.</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>$errors.exist() | |
$errors.exist("password") | |
</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getSize()"> | |
<strong>getSize()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns the number of action messages queued. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
int getSize() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
int getSize(String property) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>property</dt> | |
<dd> | |
<parameter name="property"> | |
The category of action messages to operate on. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
The number of action messages. | |
</returns> | |
</dd> | |
</dl> | |
<p>Calling <code>getSize()</code> without the <code>property</code> parameter returns the total | |
number of queued action messages. The <code>property</code> parameter can be used to | |
obtain the number of queued action messages for a specific category.</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>$messages.getSize() | |
$messages.size | |
$messages.getSize("password")</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getGlobal()"> | |
<strong>getGlobal()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
This a convenience method and the equivalent of | |
<code>$messages.get($messages.globalName)</code> | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
List getGlobal() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
A list of all messages stored under the "global" property. | |
</returns> | |
</dd> | |
</dl> | |
<p>See the section on get() for more information.</p> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="getAll()"> | |
<strong>getAll()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns a list of localized action messages for all action messages queued. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
List getAll() | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
List getAll(String bundle) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>bundle</dt> | |
<dd> | |
<parameter name="bundle"> | |
The (non-default) message-resources bundle that holds the action messages. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
If the message resources are lacking an action message message for a | |
particular message key, the key itself is used as an action message | |
and a warning is logged. | |
</returns> | |
</dd> | |
</dl> | |
<p>The following example shows a macro to render the action messages:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>#macro (messagesMarkup) | |
#if ($messages.exist()) | |
<ul> | |
#foreach ($e in $messages.all ) | |
<li>$e</li> | |
#end | |
</ul> | |
#end | |
#end</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>This produces output similar to the following:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><ul> | |
<li>This is the first action message in the queue.</li> | |
<li>This is the second action message in the queue.</li> | |
</ul></sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
<table border="0" cellspacing="0" cellpadding="2" width="100%"> | |
<tr> | |
<td colspan="2" bgcolor="#525D76"> | |
<font color="#ffffff" face="arial,helvetica.sanserif"> | |
<a name="get()"> | |
<strong>get()</strong></a></font> | |
</td> | |
</tr> | |
<tr> | |
<td NOWRAP> </td> | |
<td> | |
<p> | |
<abstract> | |
Returns a list of localized action messages for a particular category | |
of action messages. | |
</abstract> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
List get(String property) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<p> | |
<table width="100%"><tr><td bgcolor="EEEEEE"> | |
<font size="+1"><code> | |
<signature> | |
List get(String property, String bundle) | |
</signature> | |
</code></font> | |
</td></tr></table> | |
</p> | |
<dl> | |
<dt><strong>Parameters</strong></dt> | |
<dd> | |
<dl> | |
<dt>property</dt> | |
<dd> | |
<parameter name="property"> | |
The category of action messages to return. | |
</parameter> | |
</dd> | |
<dt>bundle</dt> | |
<dd> | |
<parameter name="bundle"> | |
The (non-default) message-resources bundle that holds the action messages. | |
</parameter> | |
</dd> | |
</dl> | |
</dd> | |
</dl> | |
<dl> | |
<dt><strong>Returns</strong></dt> | |
<dd> | |
<returns> | |
A <code>java.util.List</code> of <code>java.lang.String</code>. | |
If no action messages exist for the specified category, | |
<code>null</code> is returned. | |
If the message resources are lacking an error message for a | |
particular message key, the key itself is used as an action message | |
and a warning is logged. | |
</returns> | |
</dd> | |
</dl> | |
<p>The following example shows a macro to render the action messages for a | |
particular category of action messages:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode>#macro (messagesMarkup $property) | |
#if ($messages.exist($property)) | |
<ul> | |
#foreach ($er in $messages.get($property) ) | |
<li>$er</li> | |
#end | |
</ul> | |
#end | |
#end</sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<p>This produces output similar to the following:</p> | |
<table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"> | |
<table width="100%" cellpadding="5" cellspacing="0" border="0"><tr><td bgcolor="#FFFFFF"> | |
<pre><sourcecode><ul> | |
<li>This is the first action message in the queue.</li> | |
<li>TThis is the second action message in the queue.</li> | |
</ul></sourcecode></pre> | |
</td></tr></table> | |
</td></tr></table> | |
<br clear="all"> | |
</td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
<!-- FOOTER SEPARATOR --> | |
<tr> | |
<td colspan="2"> | |
<hr noshade="" size="1"/> | |
</td> | |
</tr> | |
<!-- PAGE FOOTER --> | |
<tr><td colspan="2"> | |
<div align="center"><font color="#525D76" size="-1"><em> | |
Copyright © 1999-2003, Apache Software Foundation | |
</em></font></div> | |
</td></tr> | |
</table> | |
</body> | |
</html> |