org.apache.velocity.tools.struts
Class ErrorsTool

java.lang.Object
  extended by org.apache.velocity.tools.struts.MessageResourcesTool
      extended by org.apache.velocity.tools.struts.ActionMessagesTool
          extended by org.apache.velocity.tools.struts.ErrorsTool

public class ErrorsTool
extends ActionMessagesTool

View tool to work with the Struts error messages.

 Template example(s):
   #if( $errors.exist() )
     <div class="errors">
     #foreach( $e in $errors.all )
       $e <br>
     #end
     </div>
   #end

 Toolbox configuration:
 <tool>
   <key>errors</key>
   <scope>request</scope>
   <class>org.apache.velocity.tools.struts.ErrorsTool</class>
 </tool>
 

This tool should only be used in the request scope.

Since VelocityTools 1.1, ErrorsTool extends ActionMessagesTool.

Since:
VelocityTools 1.0
Version:
$Id: ErrorsTool.java 479724 2006-11-27 18:49:37Z nbubna $
Author:
Gabe Sidler, Nathan Bubna

Field Summary
 
Fields inherited from class org.apache.velocity.tools.struts.ActionMessagesTool
actionMsgs, LOG
 
Fields inherited from class org.apache.velocity.tools.struts.MessageResourcesTool
application, locale, request, resources
 
Constructor Summary
ErrorsTool()
           
 
Method Summary
 java.lang.String getMsgs()
          Renders the queued error messages as a list.
 java.lang.String getMsgs(java.lang.String property)
          Renders the queued error messages of a particual category as a list.
 java.lang.String getMsgs(java.lang.String property, java.lang.String bundle)
          Renders the queued error messages of a particual category as a list.
 void init(java.lang.Object obj)
          Initializes this tool.
 
Methods inherited from class org.apache.velocity.tools.struts.ActionMessagesTool
exist, exist, get, get, getAll, getAll, getGlobal, getGlobalName, getSize, getSize
 
Methods inherited from class org.apache.velocity.tools.struts.MessageResourcesTool
getResources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ErrorsTool

public ErrorsTool()
Method Detail

init

public void init(java.lang.Object obj)
Initializes this tool.

Overrides:
init in class ActionMessagesTool
Parameters:
obj - the current ViewContext
Throws:
java.lang.IllegalArgumentException - if the param is not a ViewContext

getMsgs

public java.lang.String getMsgs()

Renders the queued error messages as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

Returns:
The formatted error messages. If no error messages are queued, an empty string is returned.

getMsgs

public java.lang.String getMsgs(java.lang.String property)

Renders the queued error messages of a particual category as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

Parameters:
property - the category of errors to render
Returns:
The formatted error messages. If no error messages are queued, an empty string is returned.

getMsgs

public java.lang.String getMsgs(java.lang.String property,
                                java.lang.String bundle)

Renders the queued error messages of a particual category as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

Parameters:
property - the category of errors to render
bundle - the message resource bundle to use
Returns:
The formatted error messages. If no error messages are queued, an empty string is returned.
Since:
VelocityTools 1.1


Copyright (c) 2003-2007 Apache Software Foundation