On 3/9/07, Strachan, Paul <[EMAIL PROTECTED]> wrote:
Hi,

I'll take a look at v1.3.1 - but ideally I should not have to hard-code 
property names for separate forms in my layout.jsp.

1.3.1 doesn't help with your issue - just an additional suggestion :-)

Can I declare an empty stub just for positioning purposes?
e.g.
 <field property="dateOfBirth" depends=""/>

If not I guess I'll just remove the "extends" for this use-case and go back to 
defining duplicate field validations.

Sorry - I've only just realized that your issue relates to the order
when you're extending one form from another. You can define empty
validations - but they get overriden by the form that "extends".
Theres an example of this in the struts-examples webapp shipped with
Struts 1.3.5 - if you look at the "double" field in the "baseTypeForm"
it has no validation defined - "typeForm" and "jsTypeForm" both extend
"baseTypeForm" - but only "typeForm" overrides the "double"
validation - adding actual rules:

http://tinyurl.com/2zaow2

Niall

Thanks
Paul


________________________________

From: Niall Pemberton [mailto:[EMAIL PROTECTED]
Sent: Fri 3/9/2007 8:08 PM
To: Jakarta Commons Users List
Subject: Re: [VALIDATOR] property order using extends attribute



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]



**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

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