类 ErrorsTool
This tool deals with Struts error messages. Errors may stem from the validation of a submitted form or from the processing of a request. If there are errors, they are made available to the view to render. A few important aspects about errors are:
- Error message strings are looked up in the message resources. Support for internationalized messages is provided.
- Error messages can have up to five replacement parameters.
- Errors have an attribute
property
that describes the category of error. This allows the view designer to place error messages precisely where an error occurred. For example, errors that apply to the entire page can be rendered at the top of the page, errors that apply to a specific input field can be rendered next to this input field. Several methods of this tool provide a parameterproperty
that allows to select a specific category of errors to operate on. Without theproperty
parameter, methods operate on all error messages.
See the Struts User's Guide, section Building View Components for more information on this topic.
Template example(s): #if( $errors.exist() ) <div class="errors"> #foreach( $e in $errors.all ) $e <br> #end </div> #end Toolbox configuration: <tools> <toolbox scope="request"> <tool class="org.apache.velocity.tools.struts.ErrorsTool"/> </toolbox> </tools>
This tool should only be used in the request scope.
Since VelocityTools 1.1, ErrorsTool extends ActionMessagesTool.
- 从以下版本开始:
- VelocityTools 1.0
- 版本:
- $Id: ErrorsTool.java 601976 2007-12-07 03:50:51Z nbubna $
- 作者:
- Gabe Sidler, Nathan Bubna
-
字段概要
从类继承的字段 org.apache.velocity.tools.struts.ActionMessagesTool
actionMsgs
从类继承的字段 org.apache.velocity.tools.struts.MessageResourcesTool
application, LOG, request
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected ActionMessages
getMsgs()
Renders the queued error messages as a list.Renders the queued error messages of a particual category as a list.Renders the queued error messages of a particual category as a list.从类继承的方法 org.apache.velocity.tools.struts.ActionMessagesTool
exist, exist, get, get, getAll, getAll, getGlobal, getGlobalName, getSize, getSize
从类继承的方法 org.apache.velocity.tools.struts.MessageResourcesTool
configure, getLocale, getResources, init
-
构造器详细资料
-
ErrorsTool
public ErrorsTool()
-
-
方法详细资料
-
getActionMessages
protected ActionMessages getActionMessages()- 覆盖:
getActionMessages
在类中ActionMessagesTool
-
getMsgs
Renders the queued error messages as a list. This method expects the message keys
errors.header
anderrors.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.- 返回:
- The formatted error messages. If no error messages are queued, an empty string is returned.
-
getMsgs
Renders the queued error messages of a particual category as a list. This method expects the message keys
errors.header
anderrors.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.- 参数:
property
- the category of errors to render- 返回:
- The formatted error messages. If no error messages are queued, an empty string is returned.
-
getMsgs
Renders the queued error messages of a particual category as a list. This method expects the message keys
errors.header
anderrors.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.- 参数:
property
- the category of errors to renderbundle
- the message resource bundle to use- 返回:
- The formatted error messages. If no error messages are queued, an empty string is returned.
- 从以下版本开始:
- VelocityTools 1.1
-