velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <>
Subject [veltools] struts+validator error keys Was: commons validator elements
Date Mon, 31 Mar 2003 23:25:28 GMT
Charles said:
> Hello all you Struts/Velocity users.
> I am using struts with velocity and I have implemented the commons
> validator.
> Works pretty well I must say.  And fast.

glad to hear it.

> Thing is, I am not sure how to
> access the error strings from Velocity.  And nowhere on the validator site
> does it really tell me where these messages go.

did you check the archives for this list?
i'm pretty sure i sent a long example email some time back.

> Are they coming from the request?  session?  So:
> $errors.prefix $error $error.suffix
>     Or
> $request.errors.prefix ....

you should be using the ErrorsTool to deal with these.  if you are, then you
should be doing something like:

#foreach( $e in $errors.foobar )
<span class="error">$e</span>

where "foobar" is the name of the field being validated.  if you do not wish
to display field validation errors individually, you can always just do:

#foreach( $e in $errors.all )
<span class="error">$e</span>

> You get the idea.  Where do they come from.

with Struts, it's my understanding that all ActionError instances go in the
ActionErrors object for the request.  when using Validator, then the
ActionError objects associated with a field being validated should be put
into ActionErrors using the fieldname as the key.

Nathan Bubna

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

View raw message