@DefaultKey(value="errors") @ValidScope(value="request") public class ErrorsTool extends ActionMessagesTool
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:
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 parameter
property
that allows to select a specific category of errors to operate
on. Without the property
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.
actionMsgs
application, LOG, request
Constructor and Description |
---|
ErrorsTool() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.struts.action.ActionMessages |
getActionMessages() |
String |
getMsgs()
Renders the queued error messages as a list.
|
String |
getMsgs(String property)
Renders the queued error messages of a particual category as a list.
|
String |
getMsgs(String property,
String bundle)
Renders the queued error messages of a particual category as a list.
|
exist, exist, get, get, getAll, getAll, getGlobal, getGlobalName, getSize, getSize
configure, getLocale, getResources, init
protected org.apache.struts.action.ActionMessages getActionMessages()
getActionMessages
in class ActionMessagesTool
public 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.
public String getMsgs(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.
property
- the category of errors to renderpublic String getMsgs(String property, 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.
property
- the category of errors to renderbundle
- the message resource bundle to useCopyright © 2002–2016 Apache Software Foundation. All rights reserved.