Author: niallp Date: Thu Mar 31 07:36:06 2005 New Revision: 159606 URL: http://svn.apache.org/viewcvs?view=rev&rev=159606 Log: Port Additional Validation Examples to 1.2.X Branch
Tow new validation examples added to struts-examples webapp: - resource/bundles examples for validation added (server side and JavaScript) - validwhen Validator examples page added Added: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties (with props) struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties (with props) struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp (with props) struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp (with props) struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp (with props) Modified: struts/core/branches/STRUTS_1_2_BRANCH/build-webapp.xml struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/MessageResources.properties struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/struts-config.xml struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/validation.xml struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/index.jsp Modified: struts/core/branches/STRUTS_1_2_BRANCH/build-webapp.xml URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/build-webapp.xml?view=diff&r1=159605&r2=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/build-webapp.xml (original) +++ struts/core/branches/STRUTS_1_2_BRANCH/build-webapp.xml Thu Mar 31 07:36:06 2005 @@ -252,6 +252,7 @@ </copy> <mkdir dir="${webapp.target}/WEB-INF/lib"/> <copy todir="${webapp.target}/WEB-INF/lib"> + <fileset dir="${struts.libs}" includes="antlr.jar"/> <fileset dir="${struts.libs}" includes="commons-*.jar"/> <fileset dir="${struts.libs}" includes="jakarta-oro.jar"/> <fileset dir="${struts.libs}" includes="struts.jar"/> Added: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties?view=auto&rev=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties (added) +++ struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties Thu Mar 31 07:36:06 2005 @@ -0,0 +1,7 @@ +empty= +bundlesForm.error.address=Address(Different Bundle) +bundlesForm.error.phone=Phone Number(Different Bundle) +bundlesForm.error.dob=Date of Birth(Different Bundle) +bundlesForm.error.age=Age(Different Bundle) +bundlesForm.errors.required=[Different Bundle]Missing Field: {0} +bundlesForm.errors.integer=[Different Bundle]Invalid Integer: {0} Propchange: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/DifferentMessageResources.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/MessageResources.properties URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/MessageResources.properties?view=diff&r1=159605&r2=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/MessageResources.properties (original) +++ struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/MessageResources.properties Thu Mar 31 07:36:06 2005 @@ -13,6 +13,10 @@ errors.maxlength={0} can not be greater than {1} characters. errors.invalid={0} is invalid. +html.li.open=<li> +html.li.close=</li> +file.location=The {0} file for this page can be found in the {1} directory. + errors.byte={0} must be an byte. errors.short={0} must be an short. errors.integer={0} must be an integer. @@ -82,7 +86,79 @@ jsTypeForm.title=JavaScript Type Form jsTypeForm.description=with JavaScript Validation and Server Validation +# Bundles Example form +bundles.title=Resource Bundles +bundlesExamples.title=Bundles Example Form +bundlesExamples.description=Examples of configuring Validator to use alternative/non-default resource bundles. +javascript.bundlesExamples.title=Javascript Bundles Example Form +javascript.bundlesExamples.description=Javascript examples of configuring Validator to use alternative/non-default resource bundles. + +bundlesForm.label.name=Name +bundlesForm.label.address=Address +bundlesForm.label.phone=Phone Number +bundlesForm.label.dob=Date of Birth +bundlesForm.label.age=Age + +bundlesExamples.notes.heading=Notes on Using Validator and Resources/Bundles: +bundlesExamples.notes1=<b>Non-Resource Messages:</b> - you can specify error messages directly in the <i>validation.xml</i> file using by setting resource="false" in <msg> element. Validation for the <i>name</i> field is an example of this. +bundlesExamples.notes2=<b>Alternative Bundles for Messages</b> - specifying an alternative bundle for an error message in the <i>validation.xml</i> file (using <msg bundle="altBundle"/>) takes precedence over any bundle specified in the <html:errors/>, <html:messages/> or <html:javascript/> tags. +bundlesExamples.notes3=<b>Alternative Bundles for Arguments</b> - specifying an alternative bundle for an error message argument in the <i>validation.xml</i> file (using <arg bundle="altBundle"/>) takes precedence over any bundle specified in the <html:errors/>, <html:messages/> or <html:javascript/> tags. +bundlesExamples.notes4=If you specify an alternative bundle for a message (using <msg bundle="altBundle"/>) , any <arg> elements which don't have a bundle specified also <i>inherit</i> the same bundle. Validation for the <i>address</i> field is an example of this. +bundlesExamples.notes5=You can specify different bundles for both the <msg> and <arg> elements in the <i>validation.xml</i>. Validation for the <i>phone</i> field is an example of this. +bundlesExamples.notes5=Validation for the <i>Date of Birth</i> field uses the default bundle for the message, but specifies and alternative bundle for the argument. +bundlesExamples.notes6=The <html:javascript/> tag now has a <i>bundle</i> attribute, so that the JavaScript messages can be generated in the same way as the <html:errors/> and <html:messages/> tags. + +empty= +bundlesForm.error.address=Address(default Bundle) +bundlesForm.error.phone=Phone Number(default Bundle) +bundlesForm.error.dob=Date of Birth(default Bundle) +bundlesForm.error.age=Age(default Bundle) +bundlesForm.errors.required=[Default Bundle]Missing Field: {0} +bundlesForm.errors.integer=[Default Bundle]Invalid Integer: {0} + +# validwhen Example form +validWhen.title=validwhen Validation +validWhenExamples.title=validwhen Example Form +validWhenExamples.description=Examples of the <i>validwhen</i> validator. + +validWhenForm.example.simple=Simple validwhen example +validWhenForm.example.simple.desc=The <i>Last Name</i> must be entered <b>IF</b> a <i>First Name</i> is present. +validWhenForm.firstName=First Name +validWhenForm.lastName=Last Name + +validWhenForm.example.both=Both Fields Example +validWhenForm.example.both.desc=Either both the fields must be present <b>OR</b> both must be absent. +validWhenForm.error.both=Either enter both or neither + +validWhenForm.example.numeric=Numeric Compare Example +validWhenForm.example.numeric.desc=Maximum value must be numeric and greater than the minimum. +validWhenForm.error.numeric=Maximum must be greater than the Minimum +validWhenForm.min=Minimum +validWhenForm.max=Maximum + +validWhenForm.example.address=Address Validation example +validWhenForm.example.address.desc=If any one of the address fields is present then <i>Address Line 1</i>, <i>City</i> and <i>State</i> must be present. <i>Address Line 2</i> is optional. +validWhenForm.address1=Address Line 1 +validWhenForm.address2=Address Line 2 +validWhenForm.city=City +validWhenForm.zip=Zip Code + +validWhenExamples.notes.heading=Tips on Using the <i>validwhen</i> Validator +validWhenExamples.notes1=Check Out the <a href="http://struts.apache.org/userGuide/dev_validator.html#validwhen">User Guide</a>. +validWhenExamples.notes2=<i>Greater Than</i> and <i>Less Than</i> (i.e. <b>></b> and <b><</b>) can't be used directly in the validation.xml - you need to use <b>&gt;</b> and <b>&lt;</b> instead. +validWhenExamples.notes3=<b>All comparisons must be enclosed in parens</b> +validWhenExamples.notes4=<b>Only two items may be joined with <i>and</i> or <i>or</i></b> - so that means if you want to test three separate things, you need to use parenthesis (brackets) appropriately - see the address validation above. + +validWhenExamples.problems.heading=Issues When (trying) to Use the <i>validwhen</i> Validator +validWhenExamples.problems1=<b>java.lang.NoClassDefFoundError antlr.TokenStream</b> - validwhen requires <b>antlr.jar</b> - its distributed in the Struts binary distribution in the <i>lib</i> folder along with all the other jars. +validWhenExamples.problems2=<b><i>JavaScript</i> Validation Not Working</b> - There is no JavaScript validator for validwhen - its server side only +validWhenExamples.problems3=<b>unexpected token: OR Error</b> - tokens <i><b>and</b></i> and <i><b>or</b></i> should be <b>lower case</b> +validWhenExamples.problems4=<b>Other <i>unexpected token</i> Errors</b> - somethings wrong with the test's value - the expression can't be parsed. You need to check it carefully to make sure its correctly specified. +validWhenExamples.problems5=<i>Its Not Working!</i> - check the logs / console for any exceptions. + + # Locale Form localeForm.fr=There are some differences on the Registration Form, JavaScript Registration Form, and Multi-page Registration form (see /WEB-INF/validation.xml). On the Type Form and JavaScript Type Form the integer field should fall in a range of 50-60 and the date field should have a format of 'dd.MM.yyyy'. localeForm.frCA=On the JavaScript Type Form the integer field should fall in a range of 100-200 and the date field should have a format of 'dd-MM-yyyy'. + localeForm.ja=On the JavaScript Type Form the integer field should fall in a range of 400-700 and the date field should have a format of 'yyyy/MM/dd'. Added: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties?view=auto&rev=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties (added) +++ struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties Thu Mar 31 07:36:06 2005 @@ -0,0 +1,7 @@ +empty= +bundlesForm.error.address=Address(Other Bundle) +bundlesForm.error.phone=Phone Number(Other Bundle) +bundlesForm.error.dob=Date of Birth(Other Bundle) +bundlesForm.error.age=Age(Other Bundle) +bundlesForm.errors.required=[Other Bundle]Missing Field: {0} +bundlesForm.errors.integer=[Other Bundle]Invalid Integer: {0} Propchange: struts/core/branches/STRUTS_1_2_BRANCH/src/examples/org/apache/struts/webapp/validator/OtherMessageResources.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/struts-config.xml URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/struts-config.xml?view=diff&r1=159605&r2=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/struts-config.xml (original) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/struts-config.xml Thu Mar 31 07:36:06 2005 @@ -18,6 +18,25 @@ <form-property name="language" type="java.lang.String" /> <form-property name="country" type="java.lang.String" /> </form-bean> + <form-bean name="bundlesForm" type="org.apache.struts.validator.DynaValidatorForm"> + <form-property name="name" type="java.lang.String" /> + <form-property name="address" 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-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" /> + <form-property name="fieldA" type="java.lang.String" /> + <form-property name="fieldB" type="java.lang.String" initial="XYZ" /> + <form-property name="min" type="java.lang.String" initial="25" /> + <form-property name="max" type="java.lang.String" initial="9" /> + <form-property name="address1" type="java.lang.String" /> + <form-property name="address2" type="java.lang.String" /> + <form-property name="city" type="java.lang.String" initial="Boston" /> + <form-property name="zip" type="java.lang.String" /> + </form-bean> </form-beans> <!-- ======================================== Global Forward Definitions --> <global-forwards> @@ -54,6 +73,28 @@ <action path="/jsType-submit" type="org.apache.struts.webapp.validator.TypeAction" name="jsTypeForm" scope="request" validate="true" input="/jsType.jsp"> <forward name="success" path="/welcome.do" /> </action> + + <!-- 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" > + <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" > + <forward name="input" path="/viewJsBundleExamples.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" > + <forward name="input" path="/viewValidWhenExamples.do" /> + </action> + <!-- Locale Action --> <action path="/locale" type="org.apache.struts.webapp.validator.LocaleAction" name="localeForm" scope="request"> <forward name="success" path="/welcome.do" /> @@ -63,6 +104,8 @@ <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" /> <!-- ============================================ Plug Ins Configuration --> <!-- Add multiple validator resource files by setting the pathnames property Modified: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/validation.xml URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/validation.xml?view=diff&r1=159605&r2=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/validation.xml (original) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/WEB-INF/validator/validation.xml Thu Mar 31 07:36:06 2005 @@ -13,6 +13,8 @@ <constant-value>^\d{5}\d*$</constant-value> </constant> </global> + + <!-- ========================= Default Formset ========================= --> <formset> <constant> <constant-name>zip</constant-name> @@ -35,7 +37,7 @@ <msg name="mask" key="registrationForm.lastname.maskmsg" /> <arg key="registrationForm.lastname.displayname" position="0" /> <arg name="maxlength" key="${var:maxlength}" resource="false" position="1"/> - <var> + <var> <var-name>mask</var-name> <var-value>^[a-zA-Z]*$</var-value> </var> @@ -254,6 +256,105 @@ <arg key="typeForm.checkbox.used.languages" /> </field> </form> + + <!-- *********** Bundles Examples Form *********** --> + <form name="bundlesForm"> + <field property="name" depends="required"> + <msg name="required" key="You have forgotten to enter the name." resource="false" /> + </field> + <field property="address" depends="required"> + <arg key="bundlesForm.error.address" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="phone" depends="required"> + <arg key="bundlesForm.error.phone" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="dob" depends="required"> + <arg key="bundlesForm.error.dob" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + </field> + <field property="age" depends="required,integer,intRange"> + <arg key="bundlesForm.error.age" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + <msg name="integer" key="bundlesForm.errors.integer" bundle="other"/> + <msg name="intRange" key="Age must be betweem 18 and 65 years." resource="false" /> + <var> + <var-name>min</var-name> + <var-value>18</var-value> + </var> + <var> + <var-name>max</var-name> + <var-value>65</var-value> + </var> + </field> + </form> + + <!-- *********** validwhen Examples Form *********** --> + <form name="validWhenForm"> + + <!-- validwhen: simple validation --> + <field property="lastName" depends="validwhen"> + <arg key="validWhenForm.lastName" /> + <var> + <var-name>test</var-name> + <var-value>((firstName == null) or (*this* != null))</var-value> + </var> + </field> + + <!-- validwhen: both fields validation --> + <field property="fieldA" depends="validwhen"> + <msg name="validwhen" key="validWhenForm.error.both" /> + <var> + <var-name>test</var-name> + <var-value>( ((fieldB == null) and (*this* == null)) or ((fieldB != null) and (*this* != null)) )</var-value> + </var> + </field> + + <!-- validwhen: numeric compare validation --> + <field property="max" depends="required,integer,validwhen"> + <arg key="validWhenForm.max" /> + <msg name="validwhen" key="validWhenForm.error.numeric" /> + <var> + <var-name>test</var-name> + <var-value>(*this* > min)</var-value> + </var> + </field> + + <!-- validwhen: address validation --> + <field property="address1" depends="validwhen"> + <arg key="validWhenForm.address1" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address2 == null) and + ( (city == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="city" depends="validwhen"> + <arg key="validWhenForm.city" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="zip" depends="validwhen"> + <arg key="validWhenForm.zip" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (city == null) )))</var-value> + </var> + </field> + </form> + + <!-- ========================= fr Formset ========================= --> </formset> <formset language="fr"> <form name="registrationForm"> @@ -359,7 +460,107 @@ </var> </field> </form> + + <!-- *********** Bundles Examples Form *********** --> + <form name="bundlesForm"> + <field property="name" depends="required"> + <msg name="required" key="You have forgotten to enter the name." resource="false" /> + </field> + <field property="address" depends="required"> + <arg key="bundlesForm.error.address" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="phone" depends="required"> + <arg key="bundlesForm.error.phone" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="dob" depends="required"> + <arg key="bundlesForm.error.dob" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + </field> + <field property="age" depends="required,integer,intRange"> + <arg key="bundlesForm.error.age" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + <msg name="integer" key="bundlesForm.errors.integer" bundle="other"/> + <msg name="intRange" key="Age must be betweem 18 and 65 years." resource="false" /> + <var> + <var-name>min</var-name> + <var-value>18</var-value> + </var> + <var> + <var-name>max</var-name> + <var-value>65</var-value> + </var> + </field> + </form> + + <!-- *********** validwhen Examples Form *********** --> + <form name="validWhenForm"> + + <!-- validwhen: simple validation --> + <field property="lastName" depends="validwhen"> + <arg key="validWhenForm.lastName" /> + <var> + <var-name>test</var-name> + <var-value>((firstName == null) or (*this* != null))</var-value> + </var> + </field> + + <!-- validwhen: both fields validation --> + <field property="fieldA" depends="validwhen"> + <msg name="validwhen" key="validWhenForm.error.both" /> + <var> + <var-name>test</var-name> + <var-value>( ((fieldB == null) and (*this* == null)) or ((fieldB != null) and (*this* != null)) )</var-value> + </var> + </field> + + <!-- validwhen: numeric compare validation --> + <field property="max" depends="required,integer,validwhen"> + <arg key="validWhenForm.max" /> + <msg name="validwhen" key="validWhenForm.error.numeric" /> + <var> + <var-name>test</var-name> + <var-value>(*this* > min)</var-value> + </var> + </field> + + <!-- validwhen: address validation --> + <field property="address1" depends="validwhen"> + <arg key="validWhenForm.address1" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address2 == null) and + ( (city == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="city" depends="validwhen"> + <arg key="validWhenForm.city" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="zip" depends="validwhen"> + <arg key="validWhenForm.zip" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (city == null) )))</var-value> + </var> + </field> + </form> + </formset> + + <!-- ========================= ja Formset ========================= --> <formset language="ja"> <constant> <constant-name>zip</constant-name> @@ -590,7 +791,106 @@ <arg key="typeForm.creditCard.displayname" /> </field> </form> + + <!-- *********** Bundles Examples Form *********** --> + <form name="bundlesForm"> + <field property="name" depends="required"> + <msg name="required" key="You have forgotten to enter the name." resource="false" /> + </field> + <field property="address" depends="required"> + <arg key="bundlesForm.error.address" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="phone" depends="required"> + <arg key="bundlesForm.error.phone" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="dob" depends="required"> + <arg key="bundlesForm.error.dob" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + </field> + <field property="age" depends="required,integer,intRange"> + <arg key="bundlesForm.error.age" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + <msg name="integer" key="bundlesForm.errors.integer" bundle="other"/> + <msg name="intRange" key="Age must be betweem 18 and 65 years." resource="false" /> + <var> + <var-name>min</var-name> + <var-value>18</var-value> + </var> + <var> + <var-name>max</var-name> + <var-value>65</var-value> + </var> + </field> + </form> + + <!-- *********** validwhen Examples Form *********** --> + <form name="validWhenForm"> + + <!-- validwhen: simple validation --> + <field property="lastName" depends="validwhen"> + <arg key="validWhenForm.lastName" /> + <var> + <var-name>test</var-name> + <var-value>((firstName == null) or (*this* != null))</var-value> + </var> + </field> + + <!-- validwhen: both fields validation --> + <field property="fieldA" depends="validwhen"> + <msg name="validwhen" key="validWhenForm.error.both" /> + <var> + <var-name>test</var-name> + <var-value>( ((fieldB == null) and (*this* == null)) or ((fieldB != null) and (*this* != null)) )</var-value> + </var> + </field> + + <!-- validwhen: numeric compare validation --> + <field property="max" depends="required,integer,validwhen"> + <arg key="validWhenForm.max" /> + <msg name="validwhen" key="validWhenForm.error.numeric" /> + <var> + <var-name>test</var-name> + <var-value>(*this* > min)</var-value> + </var> + </field> + + <!-- validwhen: address validation --> + <field property="address1" depends="validwhen"> + <arg key="validWhenForm.address1" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address2 == null) and + ( (city == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="city" depends="validwhen"> + <arg key="validWhenForm.city" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="zip" depends="validwhen"> + <arg key="validWhenForm.zip" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (city == null) )))</var-value> + </var> + </field> + </form> </formset> + + <!-- ========================= fr-CA Formset ========================= --> <formset language="fr" country="CA"> <form name="registrationForm"> <field property="lastName" depends="required,mask"> @@ -695,5 +995,103 @@ </var> </field> </form> + + <!-- *********** Bundles Examples Form *********** --> + <form name="bundlesForm"> + <field property="name" depends="required"> + <msg name="required" key="You have forgotten to enter the name." resource="false" /> + </field> + <field property="address" depends="required"> + <arg key="bundlesForm.error.address" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="phone" depends="required"> + <arg key="bundlesForm.error.phone" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" bundle="other" /> + </field> + <field property="dob" depends="required"> + <arg key="bundlesForm.error.dob" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + </field> + <field property="age" depends="required,integer,intRange"> + <arg key="bundlesForm.error.age" bundle="different" /> + <msg name="required" key="bundlesForm.errors.required" /> + <msg name="integer" key="bundlesForm.errors.integer" bundle="other"/> + <msg name="intRange" key="Age must be betweem 18 and 65 years." resource="false" /> + <var> + <var-name>min</var-name> + <var-value>18</var-value> + </var> + <var> + <var-name>max</var-name> + <var-value>65</var-value> + </var> + </field> + </form> + + <!-- *********** validwhen Examples Form *********** --> + <form name="validWhenForm"> + + <!-- validwhen: simple validation --> + <field property="lastName" depends="validwhen"> + <arg key="validWhenForm.lastName" /> + <var> + <var-name>test</var-name> + <var-value>((firstName == null) or (*this* != null))</var-value> + </var> + </field> + + <!-- validwhen: both fields validation --> + <field property="fieldA" depends="validwhen"> + <msg name="validwhen" key="validWhenForm.error.both" /> + <var> + <var-name>test</var-name> + <var-value>( ((fieldB == null) and (*this* == null)) or ((fieldB != null) and (*this* != null)) )</var-value> + </var> + </field> + + <!-- validwhen: numeric compare validation --> + <field property="max" depends="required,integer,validwhen"> + <arg key="validWhenForm.max" /> + <msg name="validwhen" key="validWhenForm.error.numeric" /> + <var> + <var-name>test</var-name> + <var-value>(*this* > min)</var-value> + </var> + </field> + + <!-- validwhen: address validation --> + <field property="address1" depends="validwhen"> + <arg key="validWhenForm.address1" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address2 == null) and + ( (city == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="city" depends="validwhen"> + <arg key="validWhenForm.city" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (zip == null) )))</var-value> + </var> + </field> + <field property="zip" depends="validwhen"> + <arg key="validWhenForm.zip" /> + <var> + <var-name>test</var-name> + <var-value>( (*this* != null) or + ( (address1 == null) and + ( (address2 == null) and + (city == null) )))</var-value> + </var> + </field> + </form> + </formset> </form-validation> Added: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp?view=auto&rev=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp (added) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp Thu Mar 31 07:36:06 2005 @@ -0,0 +1,73 @@ +<%@ 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="bundlesExamples.title" /></title> + <html:base /> + </head> + <body bgcolor="white"> + + <p><strong><bean:message key="bundlesExamples.description"/></strong></p> + <p><i><bean:message key="file.location" arg0="validation.xml" arg1="/webapps/struts-examples/WEB-INF/validator"/></i></h2> + + <html:form action="validateBundleExamples"> + <table border="0"> + + <!-- Name Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.name" /></b></td> + <td align="left"><html:text property="name" size="20" maxlength="25" /></td> + <td align="left"><font color="red"><html:errors property="name" header="empty"/></font> </td> + </tr> + + <!-- Address Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.address" /></b></td> + <td align="left"><b><html:text property="address" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="address" header="empty"/></font> </td> + </tr> + + <!-- Phone Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.phone" /></b></td> + <td align="left"><b><html:text property="phone" size="20" maxlength="15" /></b></td> + <td align="left"><font color="red"><html:errors property="phone" header="empty"/></font> </td> + </tr> + + <!-- Date of Birth Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.dob" /></b></td> + <td align="left"><b><html:text property="dob" size="20" maxlength="10" /></b></td> + <td align="left"><font color="red"><html:errors property="dob" header="empty"/></font> </td> + </tr> + + <!-- Age Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.age" /></b></td> + <td align="left"><b><html:text property="age" size="20" maxlength="5" /></b></td> + <td align="left"><font color="red"><html:errors property="age" header="empty"/></font> </td> + </tr> + + <!-- Buttons --> + <tr align="center"> + <td colspan="2"><html:submit><bean:message key="button.save" /></html:submit> + <html:reset><bean:message key="button.reset" /></html:reset> + <html:cancel><bean:message key="button.cancel" /></html:cancel></td> + <td> </td> + </tr> + </table> + </html:form> + + <hr /> + <br /> + <p><strong><bean:message key="bundlesExamples.notes.heading"/></strong></p> + <ul> + <li><bean:message key="bundlesExamples.notes1"/></li> + <li><bean:message key="bundlesExamples.notes2"/></li> + <li><bean:message key="bundlesExamples.notes3"/></li> + <li><bean:message key="bundlesExamples.notes4"/></li> + <li><bean:message key="bundlesExamples.notes5"/></li> + <li><bean:message key="bundlesExamples.notes6"/></li> + </ul> + + </body> +</html:html> Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamples.jsp ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Added: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp?view=auto&rev=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp (added) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp Thu Mar 31 07:36:06 2005 @@ -0,0 +1,68 @@ +<%@ 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.bundlesExamples.title" /></title> + <html:base /> + </head> + <body bgcolor="white"> + + <p><strong><bean:message key="javascript.bundlesExamples.description"/></strong></p> + <p><i><bean:message key="file.location" arg0="validation.xml" arg1="/webapps/struts-examples/WEB-INF/validator"/></i></h2> + + <html:errors prefix="html.li.open" suffix="html.li.close"/> + + <html:form action="validateJsBundleExamples" onsubmit="return validateBundlesForm(this);"> + <table border="0"> + <!-- Name Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.name" /></b></td> + <td align="left"><html:text property="name" size="15" maxlength="15" /></td> + </tr> + + <!-- Address Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.address" /></b></td> + <td align="left"><b><html:text property="address" size="25" maxlength="15" /></b></td> + </tr> + + <!-- Phone Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.phone" /></b></td> + <td align="left"><b><html:text property="phone" size="25" maxlength="15" /></b></td> + </tr> + + <!-- Date of Birth Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.dob" /></b></td> + <td align="left"><b><html:text property="dob" size="25" maxlength="15" /></b></td> + </tr> + + <!-- Age Field --> + <tr> + <td align="right"><b><bean:message key="bundlesForm.label.age" /></b></td> + <td align="left"><b><html:text property="age" size="25" maxlength="15" /></b></td> + </tr> + + <!-- Buttons --> + <tr align="center"> + <td colspan="2"><html:submit><bean:message key="button.save" /></html:submit> + <html:reset><bean:message key="button.reset" /></html:reset> + <html:cancel><bean:message key="button.cancel" /></html:cancel></td> + </tr> + + </table> + </html:form> + <hr /> + <br /> + <p><strong><bean:message key="bundlesExamples.notes.heading"/></strong></p> + <ul> + <li><bean:message key="bundlesExamples.notes1"/></li> + <li><bean:message key="bundlesExamples.notes2"/></li> + <li><bean:message key="bundlesExamples.notes3"/></li> + <li><bean:message key="bundlesExamples.notes4"/></li> + <li><bean:message key="bundlesExamples.notes5"/></li> + <li><bean:message key="bundlesExamples.notes6"/></li> + </ul> + <html:javascript formName="bundlesForm" dynamicJavascript="true" staticJavascript="true" /> + </body> +</html:html> Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/bundleExamplesJS.jsp ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/index.jsp URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/index.jsp?view=diff&r1=159605&r2=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/index.jsp (original) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/index.jsp Thu Mar 31 07:36:06 2005 @@ -42,8 +42,6 @@ </li> </ul> -<p> </p> - <h3><bean:message key="typeForm.title"/></h3> <ul> <li> @@ -56,7 +54,25 @@ </li> </ul> -<p> </p> +<h3><bean:message key="bundles.title"/></h3> +<ul> + <li> + <html:link action="/viewBundleExamples"><bean:message key="bundlesExamples.title"/></html:link> - + <bean:message key="bundlesExamples.description"/> + </li> + <li> + <html:link action="/viewJsBundleExamples"><bean:message key="javascript.bundlesExamples.title"/></html:link> - + <bean:message key="javascript.bundlesExamples.description"/> + </li> +</ul> + +<h3><bean:message key="validWhen.title"/></h3> +<ul> + <li> + <html:link action="/viewValidWhenExamples"><bean:message key="validWhenExamples.title"/></html:link> - + <bean:message key="validWhenExamples.description"/> + </li> +</ul> <h3>Change Language | Changez Le Langage</h3> <ul> Added: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp URL: http://svn.apache.org/viewcvs/struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp?view=auto&rev=159606 ============================================================================== --- struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp (added) +++ struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp Thu Mar 31 07:36:06 2005 @@ -0,0 +1,109 @@ +<%@ 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="validWhenExamples.title" /></title> + <html:base /> + </head> + <body bgcolor="white"> + + <h2><bean:message key="validWhenExamples.description"/></h2> + <p><i><bean:message key="file.location" arg0="validation.xml" arg1="/webapps/struts-examples/WEB-INF/validator"/></i></h2> + + <html:form action="validateValidWhenExamples"> + <table border="0"> + + <!-- Simple Validation --> + <p><strong><font color="blue"><bean:message key="validWhenForm.example.simple"/></font></strong> + <bean:message key="validWhenForm.example.simple.desc"/></p> + <table border="0"> + <tr> + <td align="right"><b><bean:message key="validWhenForm.firstName" /></b></td> + <td align="left"><b><html:text property="firstName" size="20" maxlength="50" /></b></td> + <td align="right"><b><bean:message key="validWhenForm.lastName" /></b></td> + <td align="left"><b><html:text property="lastName" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="lastName" header="empty"/></font> </td> + </tr> + </table> + + <!-- Both Fields --> + <p><strong><font color="blue"><bean:message key="validWhenForm.example.both"/></font></strong> + <bean:message key="validWhenForm.example.both.desc"/></p> + <table border="0"> + <tr> + <td align="left"><b><html:text property="fieldA" size="10" maxlength="10" /></b></td> + <td align="left"><b><html:text property="fieldB" size="10" maxlength="10" /></b></td> + <td align="left"><font color="red"><html:errors property="fieldA" header="empty"/></font> </td> + </tr> + </table> + + <!-- Numeric Compare Validation --> + <p><strong><font color="blue"><bean:message key="validWhenForm.example.numeric"/></font></strong> + <bean:message key="validWhenForm.example.numeric.desc"/></p> + <table border="0"> + <tr> + <td align="right"><b><bean:message key="validWhenForm.min" /></b></td> + <td align="left"><b><html:text property="min" size="10" maxlength="10" /></b></td> + <td align="right"><b><bean:message key="validWhenForm.max" /></b></td> + <td align="left"><b><html:text property="max" size="10" maxlength="10" /></b></td> + <td align="left"><font color="red"><html:errors property="max" header="empty"/></font> </td> + </tr> + </table> + + <!-- Address Validation --> + <p><strong><font color="blue"><bean:message key="validWhenForm.example.address"/></font></strong> + <bean:message key="validWhenForm.example.address.desc"/></p> + <table border="0"> + <tr> + <td align="right"><b><bean:message key="validWhenForm.address1" /></b></td> + <td align="left"><b><html:text property="address1" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="address1" header="empty"/></font> </td> + </tr> + <tr> + <td align="right"><b><bean:message key="validWhenForm.address2" /></b></td> + <td align="left"><b><html:text property="address2" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="address2" header="empty"/></font> </td> + </tr> + <tr> + <td align="right"><b><bean:message key="validWhenForm.city" /></b></td> + <td align="left"><b><html:text property="city" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="city" header="empty"/></font> </td> + </tr> + <tr> + <td align="right"><b><bean:message key="validWhenForm.zip" /></b></td> + <td align="left"><b><html:text property="zip" size="20" maxlength="50" /></b></td> + <td align="left"><font color="red"><html:errors property="zip" header="empty"/></font> </td> + </tr> + </table> + + <!-- Buttons --> + <table border="0"> + <tr> + <td><html:submit><bean:message key="button.save" /></html:submit></td> + <td><html:reset><bean:message key="button.reset" /></html:reset></td> + <td><html:cancel><bean:message key="button.cancel" /></html:cancel></td> + </tr> + </table> + </html:form> + + <hr /> + <br /> + <p><strong><bean:message key="validWhenExamples.notes.heading"/></strong></p> + <ul> + <li><bean:message key="validWhenExamples.notes1"/></li> + <li><bean:message key="validWhenExamples.notes2"/></li> + <li><bean:message key="validWhenExamples.notes3"/></li> + <li><bean:message key="validWhenExamples.notes4"/></li> + </ul> + + <br /> + <p><strong><bean:message key="validWhenExamples.problems.heading"/></strong></p> + <ul> + <li><bean:message key="validWhenExamples.problems1"/></li> + <li><bean:message key="validWhenExamples.problems2"/></li> + <li><bean:message key="validWhenExamples.problems3"/></li> + <li><bean:message key="validWhenExamples.problems4"/></li> + <li><bean:message key="validWhenExamples.problems5"/></li> + </ul> + + </body> +</html:html> Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/core/branches/STRUTS_1_2_BRANCH/web/examples/validator/validWhenExamples.jsp ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]