You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Paul Harrison <Pa...@chp.co.uk> on 2004/08/10 18:59:47 UTC

Accessing Validation Errors from Velocity

I still have a problem with Struts Validator appearing to use
ActionErrors to place errors onto the session. The only way I seem to be
able to pick them up is by using $errors in velocity.

As ActionErrors has been deprecated perhaps this is a bug?

As I am not sure whether this is an issue with the Validator, Velocity
or the link tool what is the best way to raise this issue as a possible
bug?

Thanks,

Paul.


-----Original Message-----
From: Paul Harrison 
Sent: 05 August 2004 18:09
To: 'velocity-user@jakarta.apache.org'
Subject: Accessing Validation Errors from Velocity

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 all
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: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Accessing Validation Errors from Velocity

Posted by Mike Kienenberger <mk...@alaska.net>.
Paul Harrison <Pa...@chp.co.uk> wrote:
> I still have a problem with Struts Validator appearing to use
> ActionErrors to place errors onto the session. The only way I seem to be
> able to pick them up is by using $errors in velocity.
> 
> As ActionErrors has been deprecated perhaps this is a bug?
> 
> As I am not sure whether this is an issue with the Validator, Velocity
> or the link tool what is the best way to raise this issue as a possible
> bug?

I don't think it's a bug.   At best it might be an enhancement for 
ActionMessagesTool.

To solve this, you'd need to write your own tool that combined the 
functionality of ErrorsTool and ActionMessagesTool.

I found it easier in the long run to simply use only ActionError(s) in my 
code.

The "deprecation" of ActionErrors is pretty weak, and I haven't noticed much 
of an effort to obsolete it on the struts dev list over the last year.  If 
it really bothers you, you could only use ActionMessages and 
ActionMessagesTool instead.

-Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Accessing Validation Errors from Velocity

Posted by "Marinó A. Jónsson" <ma...@centrum.is>.
I'm not sure what VelocityStrutsLink is - but if you are using Velocity
Tools 1.1 you should know that it only supports Struts 1.1.

If you want Struts 1.2 support you have to check out the Velocity Tools HEAD
from CVS (Velocity Tools 1.2-dev).  I'm using Struts 1.2 with Velocity Tools
1.2-dev and I haven't had any trouble with the messages from Validator or
custom error messages (using the addErrors(request, errors) method in the
relevant Action).

cheers,
Marinó

> -----Original Message-----
> From: Paul Harrison [mailto:PaulH@chp.co.uk] 
> Sent: 10. ágúst 2004 17:00
> To: Velocity Developers List
> Subject: Accessing Validation Errors from Velocity
> 
> 
> I still have a problem with Struts Validator appearing to use 
> ActionErrors to place errors onto the session. The only way I 
> seem to be able to pick them up is by using $errors in velocity.
> 
> As ActionErrors has been deprecated perhaps this is a bug?
> 
> As I am not sure whether this is an issue with the Validator, 
> Velocity or the link tool what is the best way to raise this 
> issue as a possible bug?
> 
> Thanks,
> 
> Paul.
> 
> 
> -----Original Message-----
> From: Paul Harrison 
> Sent: 05 August 2004 18:09
> To: 'velocity-user@jakarta.apache.org'
> Subject: Accessing Validation Errors from Velocity
> 
> 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 all 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: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org