Programming Jakarta Struts, 2nd Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming Jakarta Struts, 2nd Edition [Electronic resources] - نسخه متنی

Chuck Cavaness

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








11.6 Internationalizing the Validation


The
Validator framework uses the application
resource bundles to generate error messages for both client-side and
server-side validation. Thus, from an I18N perspective, much of the
work for displaying language-specific messages to the user is
included within the framework.

It was mentioned earlier that the formset element
in the validation.xml file supports attributes
related to internationalization. Those attributes are
language, country, and
variant. As you know, these attributes correspond
to the java.util.Locale class. If you
don't specify these attributes, the default
Locale is used.

If your application has I18N validation requirements, you will need
to create separate formset elements, one for each
Locale that you need to support for each form that
you need to validate. For example, if your application has to support
validation for a form called registrationForm for
both the default locale and the French locale, the
validation.xml file should contain two
formset elementsone for the default locale
and the other for the French locale. This is shown in the following
fragment:

<formset>
<form name="registrationForm">
<field
property="firstName"
depends="required,mask,minLength">
<arg0 key="registrationForm.firstname.displayname"/>
<var>
<var-name>mask</var-name>
<var-value>^\w+$</var-value>
</var>
<var>
<var-name>minLength</var-name>
<var-value>5</var-value>
</var>
</field>
</form>
</formset>
<formset language="fr">
<form name="registrationForm">
<field
property="firstName"
depends="required,mask,minLength">
<arg0 key="registrationForm.firstname.displayname"/>
<var>
<var-name>mask</var-name>
<var-value>^\w+$</var-value>
</var>
</field>
</form>
</formset>


    / 181