You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Hodgetts <ph...@agilelogic.com> on 2003/03/17 02:41:18 UTC
Validator Localization
I'm trying to localize validations where I have some fields that
only appear in certain locales, and therefore only need to be
validated under those locales.
In Struts in Action, Ted talks about adding attributes to the
<form> tag. But it looks like under the newer Commons Validator,
the localization happens at the <formset> tag.
Given the following validation.xml (abbreviated a bit - it's
actually a lot larger than this):
<form-validation>
<formset>
<form name="infoContactForm">
<field property="contactFName" depends="required">
<arg0 key="formFieldLabel.contactFName" />
</field>
</form>
</formset>
<formset language="en" country="UK">
<form name="infoMailingListForm">
<field property="mailingListPostcode" depends="required, mask">
<arg0 key="formFieldLabel.mailingListPostcode"/>
</field>
</form>
</formset>
<formset language="en" country="US">
<form name="infoMailingListForm">
<field property="mailingListZip" depends="required, mask">
<arg0 key="formFieldLabel.mailingListZip"/>
</field>
</form>
</formset>
</form-validation>
When I set the locale to en_UK or en_US, the Postcode or Zip
fields do not get validated. The FName field always gets
validated under any locale. What do I need to do to set up
for and trigger the locale-specific validation to happen?
Thanks much,
Paul
-----
Paul Hodgetts -- Principal Consultant
Agile Logic -- www.agilelogic.com
Consulting, Coaching, Training -- On-Site & Out-Sourced Development
Java, J2EE, C++, OOA/D -- Agile Methods/XP/Scrum, Use Cases, UI/IA
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Validator Localization
Posted by Paul Hodgetts <ph...@agilelogic.com>.
In my original example, the form name should be the same
in all the formsets. That was just a copy/paste error
in the email, but thanks to the couple of folks that
pointed that out to me by email.
I still can't figure out how to get the validations for
the locales to fire.
I wrote:
> I'm trying to localize validations where I have some fields that
> only appear in certain locales, and therefore only need to be
> validated under those locales.
>
> In Struts in Action, Ted talks about adding attributes to the
> <form> tag. But it looks like under the newer Commons Validator,
> the localization happens at the <formset> tag.
>
> Given the following validation.xml (abbreviated a bit - it's
> actually a lot larger than this):
>
> <form-validation>
> <formset>
> <form name="infoContactForm">
*** should be: infoMailingListForm ***
> <field property="contactFName" depends="required">
> <arg0 key="formFieldLabel.contactFName" />
> </field>
> </form>
> </formset>
> <formset language="en" country="UK">
> <form name="infoMailingListForm">
> <field property="mailingListPostcode" depends="required, mask">
> <arg0 key="formFieldLabel.mailingListPostcode"/>
> </field>
> </form>
> </formset>
> <formset language="en" country="US">
> <form name="infoMailingListForm">
> <field property="mailingListZip" depends="required, mask">
> <arg0 key="formFieldLabel.mailingListZip"/>
> </field>
> </form>
> </formset>
> </form-validation>
>
> When I set the locale to en_UK or en_US, the Postcode or Zip
> fields do not get validated. The FName field always gets
> validated under any locale. What do I need to do to set up
> for and trigger the locale-specific validation to happen?
>
> Thanks much,
> Paul
> -----
> Paul Hodgetts -- Principal Consultant
> Agile Logic -- www.agilelogic.com
> Consulting, Coaching, Training -- On-Site & Out-Sourced Development
> Java, J2EE, C++, OOA/D -- Agile Methods/XP/Scrum, Use Cases, UI/IA
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org