Class ErrorsTool
- java.lang.Object
-
- org.apache.velocity.tools.struts.MessageResourcesTool
-
- org.apache.velocity.tools.struts.ActionMessagesTool
-
- 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
Constructors Constructor Description ErrorsTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMsgs()Renders the queued error messages as a list.java.lang.StringgetMsgs(java.lang.String property)Renders the queued error messages of a particual category as a list.java.lang.StringgetMsgs(java.lang.String property, java.lang.String bundle)Renders the queued error messages of a particual category as a list.voidinit(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
-
-
-
-
Method Detail
-
init
public void init(java.lang.Object obj)
Initializes this tool.- Overrides:
initin classActionMessagesTool- 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.headeranderrors.footerin 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.headeranderrors.footerin 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.headeranderrors.footerin 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 renderbundle- 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
-
-