struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glenn, Scott" <>
Subject RE: Validation error messages
Date Mon, 02 Feb 2004 16:30:15 GMT
Thanks Steve, 

That's what I'm doing when I implement my own custom validation routines, but what about the
standard Struts validation rules (which are implemented declaratively), so you don't explicitly
create any ActionError objects?? 

For example, we might have a validation.xml snippet like:-
		<form name="addRecipientForm">
		  <field property="email" depends="required, email">
			<arg0 key=""/>

which checks for a mandatory well formatted mail address. If you enter "abc", Struts generates
an ActionError object containing:-

	"Recipient's email address is an invalid e-mail address"

(providing you have the following resources....'s email address{0} is an invalid e-mail address.


So I don't specifically create any ActionError objects ..... Is there no way I can declaratively
(ie. in the validation.xml) inform the rule that I'd like the submitted value inserted rather
than a textual string from the AppResources?

Hope that explains the problem a little better....



-----Original Message-----
From: Hunt, Steve [] 
Sent: 02 February 2004 15:49
To: 'Struts Users Mailing List'
Subject: RE: Validation error messages

in the resource file where the error message is defined use {0} to
parametize it.
address.invalid=Address {0} is not a valid email address.

When you construct the actionError add the parameter to the constructor ie.
new ActionError("address.invalid", address)


-----Original Message-----
From: Glenn, Scott []
Sent: 02 February 2004 14:45
To: 'Struts Users Mailing List'
Subject: Validation error messages

I might be missing something obvious here, but is there an easy way to get
the submitted value to become part of the your error message?

So, for example, if the user enters "abc" in an email field, I'd like a
message saying :-

	Address "abc" is not a valid email address.

I can get this behaviour when I write my own custom validation routines, but
what about the base Struts validation rules ... can they be configured to
display the entered value, as opposed to a string from the AppResources




This message contains information that may be privileged or confidential and is the property
of the Cap Gemini Ernst & Young Group. It is intended only for the person to whom it is
addressed. If you are not the intended recipient, you are not authorised to read, print, retain,
copy, disseminate,
distribute, or use this message or any part thereof. If you receive this message in error,
please notify the sender immediately and delete all copies of this message.

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message