Stripes Tag Library
Tag errors


The errors tag has two modes, one where it displays all validation errors in a list and a second mode when there is a single enclosed field-error tag that has no name attribute in which case this tag iterates over the body, displaying each error in turn in place of the field-error tag.

In the first mode, where the default output is used, it is possible to change the output for the entire application using a set of resources in the error messages bundle (StripesResources.properties unless you have configured another). If the properties are undefined, the tag will output the text "Validation Errors" in a div with css class errorHeader, then output an unordered list of error messages. The following four resource strings (shown with their default values) can be modified to create different default ouput:

The second mode allows customization of the output for a specific page by nesting the following tag inside the errors tag: <stripes:individual-error>, <stripes:error-header> and <stripes:error-footer>. An example, re-creating the default output using this technique follows:

<stripes:errors>
     <stripes:errors-header><div class="errorHeader">Validation Errors</div><ul></stripes:errors-header>
     <li><stripes:individual-error/></li>
     <stripes:errors-footer></ul></stripes:errors-footer>
</stripes:errors>

The errors tag can be used to display errors for a single field by supplying it with a 'field' attribute which matches the name of a field on the page. In this case the tag will display only if errors exist for the named field. In this mode the tag will first look for resources named:

If the fieldErrors resources cannot be found, the tag will default to using the sames resources and defaults as when displaying for all fields.

Similar to the above, field specific, manner of display the errors tag can also be used to output only errors not associated with a field, i.e. global errors. This is done by setting the globalErrorsOnly attribute to true.

This tag has several ways of being attached to the errors of a specific action request. If the tag is inside a form tag, it will display only errors that are associated with that form. If supplied with an 'action' attribute, it will display errors only errors associated with a request to that URL. Finally, if neither is the case, it will display errors associated with the action bean for the current request.



Tag Information
Tag Classnet.sourceforge.stripes.tag.ErrorsTag
TagExtraInfo Classnet.sourceforge.stripes.tag.ErrorsTagExtraInfo
Body ContentJSP
Display Nameerrors

Attributes
NameRequiredRequest-timeTypeDescription
actionfalsetruejava.lang.String If supplied, the errors tag will only output errors for a form that posted to the supplied action path. Can be used when there are multiple forms on the page and you wish to display errors in different places for each form, but not necessarily inside of the form tags.
beanclassfalsetruejava.lang.Object The fully qualified name of an ActionBean class, or alternatively a Class instance for an ActionBean class. An alternative to the 'action' attribute, the 'beanclass' attribute will generate an action appropriate for the ActionBean identified. Note that if an "ActionBean" that does not yet exist is identified an exception will be thrown!
fieldfalsetruejava.lang.String If supplied, the errors tag will only output errors associated with the named field.
globalErrorsOnlyfalsetruejava.lang.String If set to true then the tag will display only errors that are not directly associated with a field, i.e. global errors.

Variables
No Variables Defined.


Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.