You define the field label using an argument, i.e.
<field property="username" depends="required">
<arg0 key="prompt.username"/>
</field>
So the validator is using the field's label to fill in the message. The
default message for errors.required is:
errors.required={0} is required.
So, it will replace {0} with the prompt.username entry that also appears as a
resource.
To display the error next to the field, you could place an <html:errors
property="username" /> next to the field. IF you do this though, realize that
Struts is going to place the errors.header, errors.footer, errors.prefix and
errors.suffix around the items. If you use the defaults that would not look
right next to a field - fine for the top of the page, but not for a field.
You'll have to change them.
Otherwise, you could use an <html:messages> tag specific for that field and
then format the html yourself as it iterates one (or possibly several) error
messages for each field.
Good luck,
Eric
-----Original Message-----
From: Zhang, Larry (L.) [mailto:[EMAIL PROTECTED]
Sent: Thu 5/15/2008 6:14 PM
To: Struts Users Mailing List
Cc:
Subject: Struts validator framework
Say if I have two text fields, one label is Please enter name:, and the
other label is Please enter SSN:. In struts validator framework, if I
need to validate these two fields using required validator, is there any
way to relate the field label to the message? Or does struts validator
support displaying the validation message right next to the field (so
that the user easily know which fields are invalid)?
Thank you very much.
---------------------------------------------------------------------
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]