Scott,
As long as the error message is set up as I said the validation framework
should put the field name at the start of the message...  But not the value
in the field.

so in your example below you might get an error message like;

Email address is a required field

if

admin.email.user=Email address

To explicitly get the value submitted into the error message I think you'd
have to take a look at the validation framework code and modify that.

Regards
Steve
-----Original Message-----
From: Glenn, Scott [mailto:[EMAIL PROTECTED]
Sent: 02 February 2004 16:30
To: 'Struts Users Mailing List'
Subject: RE: Validation error messages


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="admin.email.user"/>
                  </field>
                </form> 

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....

        admin.email.pdf=Recipient's email address
        errors.email={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....

Cheers, 

Scott.





-----Original Message-----
From: Hunt, Steve [mailto:[EMAIL PROTECTED] 
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.
eg
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)

Regards
Steve

-----Original Message-----
From: Glenn, Scott [mailto:[EMAIL PROTECTED]
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
bindle?

Cheers,

Scott.


 


=======================================================
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to