You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2005/09/17 05:40:14 UTC
svn commit: r289695 - in /struts/apps/trunk/examples/src:
java/org/apache/struts/webapp/validator/ webapp/WEB-INF/validator/
webapp/validator/
Author: niallp
Date: Fri Sep 16 20:39:56 2005
New Revision: 289695
URL: http://svn.apache.org/viewcvs?rev=289695&view=rev
Log:
Update the struts-examples webapp with pages demonstrating use localized variables with Commons Validator.
Added:
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties (with props)
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties (with props)
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties (with props)
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties (with props)
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties (with props)
struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties (with props)
struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp (with props)
struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp (with props)
Modified:
struts/apps/trunk/examples/src/webapp/WEB-INF/validator/struts-config.xml
struts/apps/trunk/examples/src/webapp/WEB-INF/validator/validation.xml
struts/apps/trunk/examples/src/webapp/validator/index.jsp
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,80 @@
+# General
+standard.title=I18N Variables
+standard.desc=Validation Configured with <i>Localized</i> Variables.
+javascript.title=Javascript I18N Variables
+javascript.desc=Javascript Validation Configured with <i>Localized</i> Variables.
+long.desc=The purpose of this page is to demonstrate <i>Validator</i> configured to use <i>variables</i> from <i>message resources</i>. So, for example, the date validator can get the format appropriate for the user's Locale - enabling localized validation using just one form in the validation config file.
+
+form.heading=Employee Form Example
+
+label.current=Current Locale
+switch.locale=Switch
+current.locale=English(US)
+locale.en_us=English(US)
+locale.en_gb=English(GB)
+
+# Field labels
+label.name=Name
+label.address=Address
+label.city=City
+label.state=State
+label.zip=Zip Code
+label.phone=Phone Number
+label.dob=Date of Birth
+label.age=Age
+label.doe=Date of Employment
+label.emplno=Employee Number
+label.salary=Annual Salary
+label.hours=Weekly Hours
+
+# Button Labels
+label.cancel=Cancel
+label.confirm=Confirm
+label.reset=Reset
+label.save=Save
+label.back=Back
+
+# Error Message Display
+errors.footer=
+errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:
+html.li.open=<li>
+html.li.close=</li>
+
+# Custom Error Messages
+msg.phone={0} is invalid, must be in {1} format.
+msg.zip.minlength={0} must be {1} characters.
+msg.zip.maxlength={0} must be {1} characters.
+msg.zip.validwhen={0} must be a 5 digit number.
+
+# Standard Error Messages
+msg.invalid={0} is invalid.
+msg.required={0} is required.
+msg.minlength={0} can not be less than {1} characters.
+msg.maxlength={0} can not be greater than {1} characters.
+msg.integer={0} must be numeric.
+msg.long={0} must be numeric.
+msg.float={0} must be numeric.
+msg.double={0} must be numeric.
+msg.date={0} is invalid, must be in {1} format.
+msg.range={0} is not in the range {1} through {2}.
+
+# Field Validation Rule Notes
+rules.heading=The above fields use the following validation rules in a <i>localized</i> way...
+rules.name=minlength and maxlength.
+rules.zip=minlength, maxlength and validwhen.
+rules.phone=mask
+rules.dob=date(<i>not strict</i>)
+rules.age=intRange.
+rules.doe=date(<i>strict</i>)
+rules.emplno=longRange.
+rules.salary=doubleRange.
+rules.hours=floatRange.
+
+# General Notes
+notes.heading=Notes Below...
+notes1=The validation config is in <b>validation.xml</b> in the <i>/webapps/struts-examples/WEB-INF/validator</i> directory.
+notes2=Two message resources bundles have been used - one for normal text and the other for validation variables:
+notes3=General text (bundle key <b>i18nExample</b>) is in <i>I18nExample.properties</i>
+notes4=Validation variables (bundle key <b>i18nVariables</b>) are in <i>I18nExampleVariables.properties</i>
+notes5=<b>N.B.</b>Its important to configure the resource bundle containing validation variables to return null if not found. See the struts-config.xml for an example of this.
+
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,25 @@
+# Validation Formats
+phone.regexp=^(\\d{4})[-](\\d{3})[-](\\d{4})$
+dob.format=MM/dd/yyyy
+doe.format=MM/dd/yyyy
+
+# Formats to display
+phone.display=####-###-####
+dob.display=mm/dd/yyyy
+doe.display=mm/dd/yyyy(strict)
+
+# Validation Variables
+name.minlength=5
+name.maxlength=15
+zip.minlength=5
+zip.maxlength=5
+zip.validwhen=((*this* >= 0) and (*this* <=99999))
+age.minimum=21
+age.maximum=60
+emplno.minimum=20000001
+emplno.maximum=29999999
+salary.minimum=5000
+salary.maximum=100000
+hours.minimum=17.5
+hours.maximum=37.5
+
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,25 @@
+# Validation Formats
+phone.regexp=^(\\d{5})[-](\\d{6})$
+dob.format=dd/MM/yyyy
+doe.format=dd/MM/yyyy
+
+# Formats to display
+phone.display=####-###-####
+dob.display=mm/dd/yyyy
+doe.display=mm/dd/yyyy(strict)
+
+# Validation Variables
+name.minlength=3
+name.maxlength=20
+zip.minlength=7
+zip.maxlength=7
+zip.validwhen=((*this* == null) and (*this* != null))
+age.minimum=18
+age.maximum=65
+emplno.minimum=30000001
+emplno.maximum=39999999
+salary.minimum=3000
+salary.maximum=70000
+hours.minimum=15
+hours.maximum=45
+
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_GB.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,25 @@
+# Validation Formats
+phone.regexp=^(\\d{4})[-](\\d{3})[-](\\d{4})$
+dob.format=MM/dd/yyyy
+doe.format=MM/dd/yyyy
+
+# Formats to display
+phone.display=####-###-####
+dob.display=mm/dd/yyyy
+doe.display=mm/dd/yyyy(strict)
+
+# Validation Variables
+name.minlength=5
+name.maxlength=15
+zip.minlength=5
+zip.maxlength=5
+zip.validwhen=((*this* >= 0) and (*this* <=99999))
+age.minimum=21
+age.maximum=60
+emplno.minimum=20000001
+emplno.maximum=29999999
+salary.minimum=5000
+salary.maximum=100000
+hours.minimum=17.5
+hours.maximum=37.5
+
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExampleVariables_en_US.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,5 @@
+current.locale=<font color="blue">English(UK)</font>
+
+label.city=Town/City
+label.state=County
+label.zip=Post Code
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_GB.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties (added)
+++ struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties Fri Sep 16 20:39:56 2005
@@ -0,0 +1,6 @@
+current.locale=<font color="green">English(US)</font>
+
+label.city=City
+label.state=State
+label.zip=Zip Code
+
Propchange: struts/apps/trunk/examples/src/java/org/apache/struts/webapp/validator/I18nExample_en_US.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified: struts/apps/trunk/examples/src/webapp/WEB-INF/validator/struts-config.xml
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/webapp/WEB-INF/validator/struts-config.xml?rev=289695&r1=289694&r2=289695&view=diff
==============================================================================
--- struts/apps/trunk/examples/src/webapp/WEB-INF/validator/struts-config.xml (original)
+++ struts/apps/trunk/examples/src/webapp/WEB-INF/validator/struts-config.xml Fri Sep 16 20:39:56 2005
@@ -25,6 +25,21 @@
<form-property name="dob" type="java.lang.String" />
<form-property name="age" type="java.lang.String" />
</form-bean>
+ <form-bean name="i18nForm" type="org.apache.struts.validator.DynaValidatorForm">
+ <form-property name="name" type="java.lang.String" />
+ <form-property name="address1" type="java.lang.String" />
+ <form-property name="address2" type="java.lang.String" />
+ <form-property name="city" type="java.lang.String" />
+ <form-property name="state" type="java.lang.String" />
+ <form-property name="zip" type="java.lang.String" />
+ <form-property name="phone" type="java.lang.String" />
+ <form-property name="dob" type="java.lang.String" />
+ <form-property name="age" type="java.lang.String" />
+ <form-property name="doe" type="java.lang.String" />
+ <form-property name="emplno" type="java.lang.String" />
+ <form-property name="salary" type="java.lang.String" />
+ <form-property name="hours" type="java.lang.String" />
+ </form-bean>
<form-bean name="validWhenForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="firstName" type="java.lang.String" initial="Fred" />
<form-property name="lastName" type="java.lang.String" />
@@ -77,21 +92,44 @@
<!-- Bundles Examples -->
<action path="/viewBundleExamples" forward="/bundleExamples.jsp" />
<action path="/validateBundleExamples" type="org.apache.struts.actions.ForwardAction" name="bundlesForm" scope="request"
- parameter="/validator/welcome.do" validate="true" input="input" >
+ parameter="/welcome.do" validate="true" input="input" >
<forward name="input" path="/viewBundleExamples.do" />
</action>
<!-- JavaScript Bundles Examples -->
<action path="/viewJsBundleExamples" forward="/bundleExamplesJS.jsp" />
<action path="/validateJsBundleExamples" type="org.apache.struts.actions.ForwardAction" name="bundlesForm" scope="request"
- parameter="/validator/welcome.do" validate="true" input="input" >
+ parameter="/welcome.do" validate="true" input="input" >
<forward name="input" path="/viewJsBundleExamples.do" />
</action>
+ <!-- i18n Example -->
+ <action path="/viewI18nExample" forward="/i18nExample.jsp" />
+ <action path="/validateI18nExample" type="org.apache.struts.actions.ForwardAction" name="i18nForm" scope="request"
+ parameter="/welcome.do" validate="true" input="input" >
+ <forward name="input" path="/viewI18nExample.do" />
+ </action>
+
+ <!-- JavaScript i18n Example -->
+ <action path="/viewJsI18nExample" forward="/i18nExampleJS.jsp" />
+ <action path="/validateJsI18nExample" type="org.apache.struts.actions.ForwardAction" name="i18nForm" scope="request"
+ parameter="/welcome.do" validate="true" input="input" >
+ <forward name="input" path="/viewJsI18nExample.do" />
+ </action>
+
+ <!-- Locale Actions -->
+ <action path="/switchI18nExample" type="org.apache.struts.webapp.validator.LocaleAction" name="localeForm" scope="request">
+ <forward name="success" path="/viewI18nExample.do" />
+ </action>
+ <action path="/switchJsI18nExample" type="org.apache.struts.webapp.validator.LocaleAction" name="localeForm" scope="request">
+ <forward name="success" path="/viewJsI18nExample.do" />
+ </action>
+
+
<!-- validwhen Examples -->
<action path="/viewValidWhenExamples" forward="/validWhenExamples.jsp" />
<action path="/validateValidWhenExamples" type="org.apache.struts.actions.ForwardAction" name="validWhenForm" scope="request"
- parameter="/validator/welcome.do" validate="true" input="input" >
+ parameter="/welcome.do" validate="true" input="input" >
<forward name="input" path="/viewValidWhenExamples.do" />
</action>
@@ -102,10 +140,30 @@
</action-mappings>
<!-- ============================================= Controller Definition -->
<controller inputForward="true" />
+
+
<!-- ===================================== Message Resources Definitions -->
<message-resources parameter="org.apache.struts.webapp.validator.MessageResources" />
<message-resources key="other" parameter="org.apache.struts.webapp.validator.OtherMessageResources" />
<message-resources key="different" parameter="org.apache.struts.webapp.validator.DifferentMessageResources" />
+
+ <!--
+ The i18nExample Page uses the following message resources.
+
+ Localized validation variables have been separated out from the general text for
+ the page into the "i18nVariables" bundle. There are two reasons for doing this:
+ 1) The main reason is to have the bundle for the variables configured
+ to return "null" if not found. If you debugging missing resource keys
+ will be a pain.
+ 2) To have the bundle for the variables configured so that Struts doesn't
+ automatically 'escape' single quotes.
+
+ -->
+ <message-resources key="i18nExample" null="false" parameter="org.apache.struts.webapp.validator.I18nExample" />
+ <message-resources key="i18nVariables" null="true" parameter="org.apache.struts.webapp.validator.I18nExampleVariables" >
+ <set-property property="escape" value="false"/>
+ </message-resources>
+
<!-- ============================================ Plug Ins Configuration -->
<!--
Add multiple validator resource files by setting the pathnames property
Modified: struts/apps/trunk/examples/src/webapp/WEB-INF/validator/validation.xml
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/webapp/WEB-INF/validator/validation.xml?rev=289695&r1=289694&r2=289695&view=diff
==============================================================================
--- struts/apps/trunk/examples/src/webapp/WEB-INF/validator/validation.xml (original)
+++ struts/apps/trunk/examples/src/webapp/WEB-INF/validator/validation.xml Fri Sep 16 20:39:56 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE form-validation PUBLIC
- "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
- "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
+ "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.2.0//EN"
+ "http://jakarta.apache.org/commons/dtds/validator_1_2_0.dtd">
<form-validation>
<global>
<constant>
@@ -257,6 +257,146 @@
</field>
</form>
+
+ <!-- ================== i18nForm Form ============================ -->
+ <form name="i18nForm">
+ <field property="name" depends="required,minlength,maxlength">
+ <msg name="required" key="msg.required" bundle="i18nExample" />
+ <msg name="minlength" key="msg.minlength" bundle="i18nExample" />
+ <msg name="maxlength" key="msg.maxlength" bundle="i18nExample" />
+ <arg key="label.name" bundle="i18nExample" />
+ <arg name="minlength" key="name.minlength" bundle="i18nVariables" />
+ <arg name="maxlength" key="name.maxlength" bundle="i18nVariables" />
+ <var resource="true" bundle="i18nVariables">
+ <var-name>minlength</var-name>
+ <var-value>name.minlength</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>maxlength</var-name>
+ <var-value>name.maxlength</var-value>
+ </var>
+ </field>
+ <field property="zip" depends="required,minlength,maxlength,validwhen">
+ <msg name="required" key="msg.required" bundle="i18nExample" />
+ <msg name="minlength" key="msg.zip.minlength" bundle="i18nExample" />
+ <msg name="maxlength" key="msg.zip.maxlength" bundle="i18nExample" />
+ <msg name="validwhen" key="msg.zip.validwhen" bundle="i18nExample" />
+ <arg key="label.zip" bundle="i18nExample" />
+ <arg key="zip.minlength" bundle="i18nVariables" />
+ <arg name="validwhen" key="zip.maxlength" bundle="i18nVariables" />
+ <var resource="true" bundle="i18nVariables">
+ <var-name>minlength</var-name>
+ <var-value>zip.minlength</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>maxlength</var-name>
+ <var-value>zip.maxlength</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>test</var-name>
+ <var-value>zip.validwhen</var-value>
+ </var>
+ </field>
+ <field property="phone" depends="required,mask">
+ <msg name="required" key="msg.required" bundle="i18nExample" />
+ <msg name="mask" key="msg.phone" bundle="i18nExample" />
+ <arg key="label.phone" bundle="i18nExample" />
+ <arg name="mask" key="phone.display" bundle="i18nVariables" />
+ <var resource="true" bundle="i18nVariables">
+ <var-name>mask</var-name>
+ <var-value>phone.regexp</var-value>
+ </var>
+ </field>
+ <field property="dob" depends="required,date">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="date" key="msg.date" bundle="i18nExample"/>
+ <arg key="label.dob" bundle="i18nExample" />
+ <arg name="date" key="dob.display" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>datePattern</var-name>
+ <var-value>dob.format</var-value>
+ </var>
+ </field>
+ <field property="age" depends="required,integer,intRange">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="integer" key="msg.integer" bundle="i18nExample"/>
+ <msg name="intRange" key="msg.range" bundle="i18nExample"/>
+ <arg key="label.age" bundle="i18nExample" />
+ <arg name="intRange" key="age.minimum" bundle="i18nVariables"/>
+ <arg name="intRange" key="age.maximum" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>min</var-name>
+ <var-value>age.minimum</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>max</var-name>
+ <var-value>age.maximum</var-value>
+ </var>
+ </field>
+ <field property="doe" depends="required,date">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="date" key="msg.date" bundle="i18nExample"/>
+ <arg key="label.doe" bundle="i18nExample" />
+ <arg name="date" key="doe.display" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>datePatternStrict</var-name>
+ <var-value>doe.format</var-value>
+ </var>
+ </field>
+
+ <field property="emplno" depends="required,long,longRange">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="long" key="msg.long" bundle="i18nExample"/>
+ <msg name="longRange" key="msg.range" bundle="i18nExample"/>
+ <arg key="label.emplno" bundle="i18nExample" />
+ <arg name="longRange" key="emplno.minimum" bundle="i18nVariables"/>
+ <arg name="longRange" key="emplno.maximum" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>min</var-name>
+ <var-value>emplno.minimum</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>max</var-name>
+ <var-value>emplno.maximum</var-value>
+ </var>
+ </field>
+
+ <field property="salary" depends="required,long,doubleRange">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="long" key="msg.long" bundle="i18nExample"/>
+ <msg name="doubleRange" key="msg.range" bundle="i18nExample"/>
+ <arg key="label.salary" bundle="i18nExample" />
+ <arg name="doubleRange" key="salary.minimum" bundle="i18nVariables"/>
+ <arg name="doubleRange" key="salary.maximum" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>min</var-name>
+ <var-value>salary.minimum</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>max</var-name>
+ <var-value>salary.maximum</var-value>
+ </var>
+ </field>
+
+ <field property="hours" depends="required,float,floatRange">
+ <msg name="required" key="msg.required" bundle="i18nExample"/>
+ <msg name="float" key="msg.float" bundle="i18nExample"/>
+ <msg name="floatRange" key="msg.range" bundle="i18nExample"/>
+ <arg key="label.hours" bundle="i18nExample" />
+ <arg name="floatRange" key="hours.minimum" bundle="i18nVariables"/>
+ <arg name="floatRange" key="hours.maximum" bundle="i18nVariables"/>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>min</var-name>
+ <var-value>hours.minimum</var-value>
+ </var>
+ <var resource="true" bundle="i18nVariables">
+ <var-name>max</var-name>
+ <var-value>hours.maximum</var-value>
+ </var>
+ </field>
+
+ </form>
+
<!-- *********** Bundles Examples Form *********** -->
<form name="bundlesForm">
<field property="name" depends="required">
@@ -995,7 +1135,6 @@
</var>
</field>
</form>
-
<!-- *********** Bundles Examples Form *********** -->
<form name="bundlesForm">
<field property="name" depends="required">
Added: struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp (added)
+++ struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp Fri Sep 16 20:39:56 2005
@@ -0,0 +1,171 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>
+<html:html>
+ <head>
+ <title><bean:message key="standard.title" bundle="i18nExample"/></title>
+ <html:base />
+ </head>
+ <body bgcolor="white">
+
+ <h2><strong><bean:message key="standard.desc" bundle="i18nExample"/></strong></h2>
+ <p><bean:message key="long.desc" bundle="i18nExample"/></p>
+
+ <hr />
+
+ <table border="0" width="80%">
+ <tr><td align="left">
+ <table border="0"><tr>
+ <td><b><bean:message key="label.current" bundle="i18nExample"/></b>: <strong><bean:message key="current.locale" bundle="i18nExample"/></strong></td>
+ <td> </td>
+ <td><html:link action="/switchI18nExample?language=en&country=US"><bean:message key="locale.en_us" bundle="i18nExample"/></html:link></td>
+ <td><html:link action="/switchI18nExample?language=en&country=GB"><bean:message key="locale.en_gb" bundle="i18nExample"/></html:link></td>
+ </tr></table>
+ </td>
+ <td align="right">
+ <html:link action="/welcome"><bean:message key="label.back" bundle="i18nExample"/></html:link>
+ </td></tr>
+ </table>
+
+ <hr />
+ <h2><bean:message key="form.heading" bundle="i18nExample"/></h2>
+
+ <html:form action="validateI18nExample">
+ <table border="0">
+
+ <!-- Name -->
+ <tr>
+ <td align="right"><b><bean:message key="label.name" bundle="i18nExample"/></b></td>
+ <td align="left"><html:text property="name" size="20" errorStyle="background-color: yellow" /></td>
+ <td align="left"><font color="red"><html:errors property="name" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Line 1 -->
+ <tr>
+ <td align="right"><b><bean:message key="label.address" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="address1" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="address1" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Line 2 -->
+ <tr>
+ <td> </td>
+ <td align="left"><b><html:text property="address2" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="address2" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address City -->
+ <tr>
+ <td align="right"><bean:message key="label.city" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="city" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="city" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address State -->
+ <tr>
+ <td align="right"><bean:message key="label.state" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="state" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="state" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Zip/Post Code -->
+ <tr>
+ <td align="right"><bean:message key="label.zip" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="zip" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="zip" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Phone -->
+ <tr>
+ <td align="right"><b><bean:message key="label.phone" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="phone" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="phone" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Date of Birth -->
+ <tr>
+ <td align="right"><b><bean:message key="label.dob" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="dob" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="dob" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Age -->
+ <tr>
+ <td align="right"><b><bean:message key="label.age" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="age" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="age" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Date of Employment -->
+ <tr>
+ <td align="right"><b><bean:message key="label.doe" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="doe" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="doe" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Employee Number -->
+ <tr>
+ <td align="right"><b><bean:message key="label.emplno" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="emplno" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="emplno" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Annual Salary -->
+ <tr>
+ <td align="right"><b><bean:message key="label.salary" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="salary" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="salary" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Weekly Hours -->
+ <tr>
+ <td align="right"><b><bean:message key="label.hours" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="hours" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="hours" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Buttons -->
+ <tr align="center">
+ <td colspan="2"><html:submit><bean:message key="label.save" bundle="i18nExample"/></html:submit>
+ <html:reset><bean:message key="label.reset" bundle="i18nExample"/></html:reset>
+ <html:cancel><bean:message key="label.cancel" bundle="i18nExample"/></html:cancel></td>
+ <td> </td>
+ </tr>
+ </table>
+ </html:form>
+
+ <hr />
+ <br />
+ <p><strong><bean:message key="rules.heading" bundle="i18nExample"/></strong></p>
+ <ul>
+ <li><strong><bean:message key="label.name" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.name" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.zip" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.zip" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.phone" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.phone" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.dob" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.dob" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.age" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.age" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.doe" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.doe" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.emplno" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.emplno" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.salary" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.salary" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.hours" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.hours" bundle="i18nExample"/>.</li>
+ </ul>
+
+ <p><strong><bean:message key="notes.heading" bundle="i18nExample"/></strong></p>
+ <ul>
+ <li><bean:message key="notes1" bundle="i18nExample"/></li>
+ <li><bean:message key="notes2" bundle="i18nExample"/></li>
+ <ul>
+ <li><bean:message key="notes3" bundle="i18nExample"/></li>
+ <li><bean:message key="notes4" bundle="i18nExample"/></li>
+ </ul>
+ <li><bean:message key="notes5" bundle="i18nExample"/></li>
+ </ul>
+
+ </body>
+</html:html>
Propchange: struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/apps/trunk/examples/src/webapp/validator/i18nExample.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp?rev=289695&view=auto
==============================================================================
--- struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp (added)
+++ struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp Fri Sep 16 20:39:56 2005
@@ -0,0 +1,173 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>
+<html:html>
+ <head>
+ <title><bean:message key="javascript.title" bundle="i18nExample" /></title>
+ <html:base />
+ </head>
+ <body bgcolor="white">
+
+ <h2><strong><bean:message key="javascript.desc" bundle="i18nExample"/></strong></h2>
+ <p><bean:message key="long.desc" bundle="i18nExample"/></p>
+
+ <hr />
+
+ <table border="0" width="80%">
+ <tr><td alig="left">
+ <table border="0"><tr>
+ <td><b><bean:message key="label.current" bundle="i18nExample"/></b>: <strong><bean:message key="current.locale" bundle="i18nExample"/></strong></td>
+ <td> </td>
+ <td><html:link action="/switchJsI18nExample?language=en&country=US"><bean:message key="locale.en_us" bundle="i18nExample"/></html:link></td>
+ <td><html:link action="/switchJsI18nExample?language=en&country=GB"><bean:message key="locale.en_gb" bundle="i18nExample"/></html:link></td>
+ </tr></table>
+ </td>
+ <td align="right">
+ <html:link action="/welcome"><bean:message key="label.back" bundle="i18nExample"/></html:link>
+ </td></tr>
+ </table>
+
+ <hr />
+ <h2><bean:message key="form.heading" bundle="i18nExample"/></h2>
+
+ <html:form action="validateI18nExample" onsubmit="return validateI18nForm(this);">
+ <table border="0">
+
+ <!-- Name -->
+ <tr>
+ <td align="right"><b><bean:message key="label.name" bundle="i18nExample"/></b></td>
+ <td align="left"><html:text property="name" size="20" errorStyle="background-color: yellow" /></td>
+ <td align="left"><font color="red"><html:errors property="name" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Line 1 -->
+ <tr>
+ <td align="right"><b><bean:message key="label.address" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="address1" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="address1" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Line 2 -->
+ <tr>
+ <td> </td>
+ <td align="left"><b><html:text property="address2" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="address2" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address City -->
+ <tr>
+ <td align="right"><bean:message key="label.city" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="city" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="city" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address State -->
+ <tr>
+ <td align="right"><bean:message key="label.state" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="state" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="state" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Address Zip/Post Code -->
+ <tr>
+ <td align="right"><bean:message key="label.zip" bundle="i18nExample" /></td>
+ <td align="left"><b><html:text property="zip" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="zip" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Phone -->
+ <tr>
+ <td align="right"><b><bean:message key="label.phone" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="phone" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="phone" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Date of Birth -->
+ <tr>
+ <td align="right"><b><bean:message key="label.dob" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="dob" size="10" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="dob" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Age -->
+ <tr>
+ <td align="right"><b><bean:message key="label.age" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="age" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="age" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Date of Employment -->
+ <tr>
+ <td align="right"><b><bean:message key="label.doe" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="doe" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="doe" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Employee Number -->
+ <tr>
+ <td align="right"><b><bean:message key="label.emplno" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="emplno" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="emplno" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Annual Salary -->
+ <tr>
+ <td align="right"><b><bean:message key="label.salary" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="salary" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="salary" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Weekly Hours -->
+ <tr>
+ <td align="right"><b><bean:message key="label.hours" bundle="i18nExample" /></b></td>
+ <td align="left"><b><html:text property="hours" size="20" errorStyle="background-color: yellow" /></b></td>
+ <td align="left"><font color="red"><html:errors property="hours" header="empty"/></font> </td>
+ </tr>
+
+ <!-- Buttons -->
+ <tr align="center">
+ <td colspan="2"><html:submit><bean:message key="label.save" bundle="i18nExample"/></html:submit>
+ <html:reset><bean:message key="label.reset" bundle="i18nExample"/></html:reset>
+ <html:cancel><bean:message key="label.cancel" bundle="i18nExample"/></html:cancel></td>
+ <td> </td>
+ </tr>
+ </table>
+ </html:form>
+
+ <hr />
+ <br />
+ <p><strong><bean:message key="rules.heading" bundle="i18nExample"/></strong></p>
+ <ul>
+ <li><strong><bean:message key="label.name" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.name" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.zip" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.zip" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.phone" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.phone" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.dob" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.dob" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.age" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.age" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.doe" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.doe" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.emplno" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.emplno" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.salary" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.salary" bundle="i18nExample"/>.</li>
+ <li><strong><bean:message key="label.hours" bundle="i18nExample"/></strong> -
+ <bean:message key="rules.hours" bundle="i18nExample"/>.</li>
+ </ul>
+
+ <p><strong><bean:message key="notes.heading" bundle="i18nExample"/></strong></p>
+ <ul>
+ <li><bean:message key="notes1" bundle="i18nExample"/></li>
+ <li><bean:message key="notes2" bundle="i18nExample"/></li>
+ <ul>
+ <li><bean:message key="notes3" bundle="i18nExample"/></li>
+ <li><bean:message key="notes4" bundle="i18nExample"/></li>
+ </ul>
+ <li><bean:message key="notes5" bundle="i18nExample"/></li>
+ </ul>
+
+ <html:javascript formName="i18nForm" dynamicJavascript="true" staticJavascript="true" />
+
+ </body>
+</html:html>
Propchange: struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/apps/trunk/examples/src/webapp/validator/i18nExampleJS.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/apps/trunk/examples/src/webapp/validator/index.jsp
URL: http://svn.apache.org/viewcvs/struts/apps/trunk/examples/src/webapp/validator/index.jsp?rev=289695&r1=289694&r2=289695&view=diff
==============================================================================
--- struts/apps/trunk/examples/src/webapp/validator/index.jsp (original)
+++ struts/apps/trunk/examples/src/webapp/validator/index.jsp Fri Sep 16 20:39:56 2005
@@ -54,6 +54,18 @@
</li>
</ul>
+<h3><bean:message key="standard.title" bundle="i18nExample"/></h3>
+<ul>
+ <li>
+ <html:link action="/viewI18nExample"><bean:message key="standard.title" bundle="i18nExample"/></html:link> -
+ <bean:message key="standard.desc" bundle="i18nExample"/>
+ </li>
+ <li>
+ <html:link action="/viewJsI18nExample"><bean:message key="javascript.title" bundle="i18nExample"/></html:link> -
+ <bean:message key="javascript.desc" bundle="i18nExample"/>
+ </li>
+</ul>
+
<h3><bean:message key="bundles.title"/></h3>
<ul>
<li>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org