On 3/9/07, Strachan, Paul <[EMAIL PROTECTED]> wrote:
Hi,
using validator 1.2.0 and struts 1.2.9 is there any way to control the order of
validation error messages output on the screen?
I would recommend upgrading to the latest Validator 1.3.1 release -
its compatible with Struts 1.2.9 and has a number of bug fixes:
http://jakarta.apache.org/commons/validator/changes-report.html
for example:
<form name="MyForm">
<field property="firstName" depends="required">
<arg key="firstName.label" resource="true"/>
</field>
<field property="lastName" depends="required">
<arg key="lastName.label" resource="true"/>
</field>
<field property="dateOfBirth" depends="date">
<arg key="dateOfBirth.label" resource="true"/>
</field>
</form>
This example displays:
o First name is required
o Last name is Required
o Date of Birth is invalid
Now if I change the validation as follows:
<form name="MyForm_fatal">
<field property="dateOfBirth" depends="date">
<arg key="dateOfBirth.label" resource="true"/>
</field>
</form>
<form name="MyForm" extends="MyForm_fatal">
<field property="firstName" depends="required">
<arg key="firstName.label" resource="true"/>
</field>
<field property="lastName" depends="required">
<arg key="lastName.label" resource="true"/>
</field>
</form>
When I validate against "MyForm" it displays:
o Date of Birth is invalid
o First name is required
o Last name is Required
Is it possible to control the order so that the date of birth message is displayed
after the last name. Possibly an optional attribute (int) on the <field>
element ?
Validator validates the fields in the order you specify them in your
validation.xml - and Struts displays messages in the order they are
added. So to control the order of messages specify the fields in the
order you want to see the messages. Alternatively you can control
messages for individual fields in struts using the "property"
attribute either on the <html:errors/> or <html:messages/> tag - for
an example see here:
http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html#section5
Niall
Thanks,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]