velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Harrison" <>
Subject RE: Accessing Validation Errors from Velocity
Date Fri, 06 Aug 2004 08:24:05 GMT

Thanks for your response. The problem is that ActionErrors.add() has
been deprecated, so it's not a long term solution.

This is problem: Struts validator seems to use ActionErrors errors,
which I can't use because they've been deprecated.



-----Original Message-----
From: Kishore Senji [] 
Sent: 05 August 2004 18:35
To: Velocity Users List
Subject: Re: Accessing Validation Errors from Velocity

To display both messages generated by Validator and you, add your
messages to the same ActionErrors instance generated by Validator.

So, in the validate() method of your ActionForm which extends
ValidatorForm, do something like the one below

public ActionErrors validate(
	ActionMapping mapping,
	HttpServletRequest request) {
	ActionErrors errors = super.validate(mapping, request);
	errors.add("myOwnMessage", new ActionMessage(...));
	return errors;

In the template, using your Errors Tool, all your messages get

Kishore Senji.

On Thu, 5 Aug 2004 18:08:40 +0100, Paul Harrison <>
> Hi,
> I've just upgraded my project to Struts 1.2.1, which I am using with
> Velocity 1.4 and VelocityStrutsLink 1.1.
> Everything is fine, except for getting back Struts validator messages.
> To pick up Struts generated validation messages I use:
> #foreach( $error in $errors.getAll() )
> <li>$error</li>
> #end
> which correctly shows the validation messages generated by the Struts
> validator.
> However when I want to place an error message on the session I can no
> longer use ActionError as it has been deprecated, so I have changed to
> ActionMessage.
> Which means I have to use:
> #foreach( $message in $messages.getAll() )
> <li>$message</li>
> #end
> to pick it up, which also works correctly.
> So I have to use $errors to pick up Struts generated validation errors
> and $messages to pick up the error messages I have generated.
> I've updated my validation-rules.xml file to 1.2.1 and have included
> the jars from Struts 1.2.1 in my project.
> How can I get both the Struts validator messages and my own generated
> messages to be accessible by one method (e.g. just $errors or just
> $messages)? Are there newer versions of Velocity or the
> VelocityStrutsLink tools I need to use?
> Thanks,
> Paul.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message