Author: husted
Date: Sun Jan  1 12:52:38 2006
New Revision: 360550

URL: http://svn.apache.org/viewcvs?rev=360550&view=rev
Log:
Validator Dev Guide
* Updates for 1.3.x

Modified:
    struts/taglib/trunk/xdocs/dev_validator.xml

Modified: struts/taglib/trunk/xdocs/dev_validator.xml
URL: 
http://svn.apache.org/viewcvs/struts/taglib/trunk/xdocs/dev_validator.xml?rev=360550&r1=360549&r2=360550&view=diff
==============================================================================
--- struts/taglib/trunk/xdocs/dev_validator.xml (original)
+++ struts/taglib/trunk/xdocs/dev_validator.xml Sun Jan  1 12:52:38 2006
@@ -103,8 +103,8 @@
     </p>
 
     <p>
-    The arguments for error messages can be set with the arg0-arg3 elements.
-    If the arg0-arg3 elements' name attribute isn't set, it will become the
+    The arguments for error messages can be set with the arg element and 
position attribute.
+    If the arg elements' name attribute isn't set, it will become the
     default arg value for the different error messages constructed.
     If the name attribute is set, you can specify the argument for a specific
     pluggable validator and then this will be used for constructing the error
@@ -118,7 +118,7 @@
     <msg
         name="mask"
         key="registrationForm.lastname.maskmsg"/>
-    <arg0 key="registrationForm.lastname.displayname"/>
+    <arg position="0" key="registrationForm.lastname.displayname"/>
     <var>
         <var-name>mask</var-name>
         <var-value>^[a-zA-Z]*$</var-value>
@@ -127,7 +127,7 @@
 ]]></source>
 
     <p>
-    By default the arg0-arg3 elements will try to look up the <code>key</code>
+    By default the arg elements will try to look up the <code>key</code>
     attribute in the message resources.
     If the resource attribute is set to false, it will pass in the value 
directly
     without retrieving the value from the message resources.
@@ -143,12 +143,12 @@
 <field
     property="integer"
     depends="required,integer,intRange">
-    <arg0 key="typeForm.integer.displayname"/>
-    <arg1
+    <arg position="0" key="typeForm.integer.displayname"/>
+    <arg position="1"
         name="intRange"
         key="${var:min}"
         resource="false"/>
-    <arg2
+    <arg position="2"
         name="intRange"
         key="${var:max}"
         resource="false"/>
@@ -174,7 +174,7 @@
               <li><strong>required</strong> - mandatory field validation. Has 
no variables.
     <source><![CDATA[
     <field property="name" depends="required">
-        <arg0 key="customer.name"/>
+        <arg position="0" key="customer.name"/>
     </field>
     ]]></source>
               </li>
@@ -188,8 +188,8 @@
                   Requires a <code>minlength</code> variable.
     <source><![CDATA[
     <field property="name" depends="required,minlength">
-        <arg0 key="customer.name"/>
-        <arg1 name="minlength" key="${var:minlength}" resource="false"/>
+        <arg position="0" key="customer.name"/>
+        <arg position="1" name="minlength" key="${var:minlength}" 
resource="false"/>
         <var><var-name>minlength</var-name><var-value>3</var-value></var>
     </field>
     ]]></source>
@@ -198,8 +198,8 @@
                   Requires a <code>maxlength</code> variable.
     <source><![CDATA[
     <field property="name" depends="required,maxlength">
-        <arg0 key="customer.name"/>
-        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
+        <arg position="0" key="customer.name"/>
+        <arg position="1" name="maxlength" key="${var:maxlength}" 
resource="false"/>
         <var><var-name>maxlength</var-name><var-value>30</var-value></var>
     </field>
     ]]></source>
@@ -211,7 +211,7 @@
     <source><![CDATA[
     <field property="name" depends="required,mask">
         <msg name="mask" key="registrationForm.lastname.maskmsg"/>
-        <arg0 key="registration.name"/>
+        <arg position="0" key="registration.name"/>
         <var><var-name>mask</var-name><var-value>^[a-zA-Z]*$</var-value></var>
     </field>
     ]]></source>
@@ -219,42 +219,42 @@
               <li><strong>byte</strong> - validates that a field can be 
converted to a Byte.
     <source><![CDATA[
     <field property="age" depends="byte">
-        <arg0 key="employee.age"/>
+        <arg position="0" key="employee.age"/>
     </field>
     ]]></source>
               </li>
               <li><strong>short</strong> - validates that a field can be 
converted to a Short.
     <source><![CDATA[
     <field property="productnumber" depends="short">
-        <arg0 key="order.prodno"/>
+        <arg position="0" key="order.prodno"/>
     </field>
     ]]></source>
               </li>
               <li><strong>integer</strong> - validates that a field can be 
converted to an Integer.
     <source><![CDATA[
     <field property="ordernumber" depends="integer">
-        <arg0 key="order.number"/>
+        <arg position="0" key="order.number"/>
     </field>
     ]]></source>
               </li>
               <li><strong>long</strong> - validates that a field can be 
converted to a Long.
     <source><![CDATA[
     <field property="ordernumber" depends="long">
-        <arg0 key="order.number"/>
+        <arg position="0" key="order.number"/>
     </field>
     ]]></source>
               </li>
               <li><strong>float</strong> - validates that a field can be 
converted to a Float.
     <source><![CDATA[
     <field property="amount" depends="float">
-        <arg0 key="sale.amount"/>
+        <arg position="0" key="sale.amount"/>
     </field>
     ]]></source>
               </li>
               <li><strong>double</strong> - validates that a field can be 
converted to a Double.
     <source><![CDATA[
     <field property="amount" depends="double">
-        <arg0 key="sale.amount"/>
+        <arg position="0" key="sale.amount"/>
     </field>
     ]]></source>
               </li>
@@ -267,13 +267,13 @@
                   length as the pattern specified (so for example 1/1/2004 
would fail with a pattern of <code>MM/dd/yyyy</code>).
     <source><![CDATA[
     <field property="saledate" depends="required,date">
-        <arg0 key="myForm.saledate"/>
+        <arg position="0" key="myForm.saledate"/>
         
<var><var-name>datePattern</var-name><var-value>MM/dd/yyyy</var-value></var>
     </field>
     ]]></source>
     <source><![CDATA[
     <field property="saledate" depends="required,date">
-        <arg0 key="sale.orderdate"/>
+        <arg position="0" key="sale.orderdate"/>
         
<var><var-name>datePatternStrict</var-name><var-value>MM/dd/yyyy</var-value></var>
     </field>
     ]]></source>
@@ -287,23 +287,23 @@
                   which must also be in the field's <code>depends</code> 
attribute.
     <source><![CDATA[
     <field property="age" depends="required,integer,intRange">
-        <arg0 key="employee.age"/>
-        <arg1 name="intRange" key="${var:min}" resource="false"/>
-        <arg2 name="intRange" key="${var:max}" resource="false"/>
+        <arg position="0" key="employee.age"/>
+        <arg position="1" name="intRange" key="${var:min}" resource="false"/>
+        <arg position="2" name="intRange" key="${var:max}" 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>
     ]]></source>
               </li>
-              <li><strong>longRange</strong> - validates that an long field is 
within a specified range.
+              <li><strong>longRange</strong> - validates that a long field is 
within a specified range.
                   Requires <code>min</code> and <code>max</code> variables to 
specify the range.
                   This validator depends on the <code>long</code> validator
                   which must also be in the field's <code>depends</code> 
attribute.
     <source><![CDATA[
     <field property="age" depends="required,long,longRange">
-        <arg0 key="employee.age"/>
-        <arg1 name="longRange" key="${var:min}" resource="false"/>
-        <arg2 name="longRange" key="${var:max}" resource="false"/>
+        <arg position="0" key="employee.age"/>
+        <arg position="1" name="longRange" key="${var:min}" resource="false"/>
+        <arg position="2" name="longRange" key="${var:max}" 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>
@@ -315,9 +315,9 @@
                   which must also be in the field's <code>depends</code> 
attribute.
     <source><![CDATA[
     <field property="ordervalue" depends="required,float,floatRange">
-        <arg0 key="order.value"/>
-        <arg1 name="floatRange" key="${var:min}" resource="false"/>
-        <arg2 name="floatRange" key="${var:max}" resource="false"/>
+        <arg position="0" key="order.value"/>
+        <arg position="1" name="floatRange" key="${var:min}" resource="false"/>
+        <arg position="2" name="floatRange" key="${var:max}" resource="false"/>
         <var><var-name>min</var-name><var-value>100</var-value></var>
         <var><var-name>max</var-name><var-value>4.99</var-value></var>
     </field>
@@ -329,9 +329,9 @@
                   which must also be in the field's <code>depends</code> 
attribute.
     <source><![CDATA[
     <field property="ordervalue" depends="required,double,doubleRange">
-        <arg0 key="employee.age"/>
-        <arg1 name="doubleRange" key="${var:min}" resource="false"/>
-        <arg2 name="doubleRange" key="${var:max}" resource="false"/>
+        <arg position="0" key="employee.age"/>
+        <arg position="1" name="doubleRange" key="${var:min}" 
resource="false"/>
+        <arg position="2" name="doubleRange" key="${var:max}" 
resource="false"/>
         <var><var-name>min</var-name><var-value>100</var-value></var>
         <var><var-name>max</var-name><var-value>4.99</var-value></var>
     </field>
@@ -340,14 +340,14 @@
               <li><strong>creditCard</strong> - validate credit card number 
format
     <source><![CDATA[
     <field property="name" depends="required, creditCard">
-        <arg0 key="customer.cardnumber"/>
+        <arg position="0" key="customer.cardnumber"/>
     </field>
     ]]></source>
               </li>
               <li><strong>email</strong> - validate email address format
     <source><![CDATA[
     <field property="customeremail" depends="email">
-        <arg0 key="customer.email"/>
+        <arg position="0" key="customer.email"/>
     </field>
     ]]></source>
               </li>
@@ -370,11 +370,11 @@
                   </ul>
     <source><![CDATA[
     <field property="custUrl" depends="url">
-        <arg0 key="customer.url"/>
+        <arg position="0" key="customer.url"/>
     </field>
 
     <field property="custUrl" depends="url">
-        <arg0 key="customer.url"/>
+        <arg position="0" key="customer.url"/>
         <var>
            <var-name>nofragments</var-name>
            <var-value>true</var-value>
@@ -397,8 +397,8 @@
     constants can be created in the formset tags.
     Constants are currently only replaced in the Field's property attribute,
     the Field's var element value attribute, the Field's msg element key
-    attribute, and Field's arg0-arg3 element's key attribute.
-    A Field's variables can also be substituted in the arg0-arg3
+    attribute, and Field's arg element's key attribute.
+    A Field's variables can also be substituted in the arg
     elements (ex: ${var:min}).
     The order of replacement is FormSet/Locale constants are replaced first,
     Global constants second, and for the arg elements variables are replaced
@@ -416,7 +416,7 @@
 <field
    property="zip"
    depends="required,mask">
-<arg0 key="registrationForm.zippostal.displayname"/>
+<arg position="0" key="registrationForm.zippostal.displayname"/>
 <var>
  <var-name>mask</var-name>
  <var-value>${zip}</var-value>
@@ -435,12 +435,12 @@
 <field
     property="integer"
     depends="required,integer,intRange">
-    <arg0 key="typeForm.integer.displayname"/>
-    <arg1
+    <arg position="0" key="typeForm.integer.displayname"/>
+    <arg position="1"
         name="intRange"
         key="${var:min}"
         resource="false"/>
-    <arg2
+    <arg position="2"
         name="intRange"
         key="${var:max}"
         resource="false"/>
@@ -464,19 +464,38 @@
     a password twice for confirmation, to make sure that the values match.)
     In addition, there are fields in a form that may only be required if
     other fields have certain values.  The <code>validwhen</code>
-    validator is designed to handle these cases.</p>
+    validator is designed to handle these cases.
+    </p>
     <p>
     The <code>validwhen</code> validator takes a single <code>var</code> field,
     called <code>test</code>.  The value of this var is a boolean expression
     which must be true in order for the validation to success.  The
-    values which are allowed in the expression are:</p>
+    values which are allowed in the expression are:
+    </p>
     <ul>
-      <li>Single or double-quoted string literals.</li>
-      <li>Integer literals in decimal, hex or octal format</li>
-      <li>The value <code>null</code> which will match against either
-      null or an empty string</li>
-      <li>Other fields in the form referenced by field name, such as
-      <code>customerAge</code></li>
+      <li>
+      The token <code>*this*</code>, which contains the value of
+      the field currently being tested
+      </li>
+      <li>
+      Other fields in the form referenced by field name, such as
+      <code>customerAge</code>
+      </li>
+      <li>
+      The token <code>null</code> which will match against either
+      null or an empty string
+      </li>
+      <li>
+      Single or double-quoted string literals.
+      </li>
+      <li>
+      Integer literals in decimal, hex or octal format
+      </li>
+   </ul>
+   <p>
+   References to indexed fields are also allowed in the expression: 
+   </p>
+   <ul>      
       <li>Indexed fields in the form referenced by an explicit integer, 
       such as <code>childLastName[2]</code></li>
       <li>Indexed fields in the form referenced by an implicit integer, 
@@ -486,8 +505,6 @@
       explicit or implicit integer, such as <code>child[].lastName</code>, 
       which will use the same index into the array as the index of the 
       field being tested.</li>
-      <li>The literal <code>*this*</code>, which contains the value of
-      the field currently being tested</li>
    </ul>
    <p>
       As an example of how this would work, consider a form with
@@ -497,12 +514,12 @@
       this using validwhen as:</p>
 <source><![CDATA[
 <field property="emailAddress" depends="validwhen">
-      <arg0 key="userinfo.emailAddress.label"/>
-        <var>
-          <var-name>test</var-name>
-          <var-value>((sendNewsletter == null) or (*this* != null))</var-value>
-        </var>
-      </field>
+  <arg position="0" key="userinfo.emailAddress.label"/>
+  <var>
+    <var-name>test</var-name>
+    <var-value>((sendNewsletter == null) or (*this* != null))</var-value>
+  </var>
+</field>
 ]]></source>
 <p>
       Which reads as: this field is valid if <code>sendNewsletter</code> is 
@@ -516,16 +533,16 @@
       If you wished to verify that every line with part number also had
       a quantity entered, you could do it with:</p>
 <source><![CDATA[
-    <field property="quantity" indexedListProperty="orderLines" 
depends="validwhen">
-      <arg0 key="orderform.quantity.label"/>
-        <var>
-          <var-name>test</var-name>
-          <var-value>((orderLines[].partNumber == null) or (*this* != 
null))</var-value>
-        </var>
-      </field>
+<field property="quantity" indexedListProperty="orderLines" 
depends="validwhen">
+  <arg position="0" key="orderform.quantity.label"/>
+  <var>
+    <var-name>test</var-name>
+    <var-value>((orderLines[].partNumber == null) or (*this* != 
null))</var-value>
+  </var>
+</field>
 ]]></source>
      <p>
-     Which reads as: This field is value if the corresponding <code>partNumber
+     Which reads as: This field is valid if the corresponding <code>partNumber
      </code> field is <code>null</code>, or this field is not 
<code>null</code>.
      </p>
      <p>
@@ -533,13 +550,13 @@
      height in inches, and if they are under 60 inches in height, it is
      an error to have checked off nbaPointGuard as a career.</p>
 <source><![CDATA[
-    <field property="nbaPointGuard" depends="validwhen">
-      <arg0 key="careers.nbaPointGuard.label"/>
-        <var>
-          <var-name>test</var-name>
-          <var-value>((heightInInches >= 60) or (*this* == null))</var-value>
-        </var>
-      </field>
+<field property="nbaPointGuard" depends="validwhen">
+  <arg position="0" key="careers.nbaPointGuard.label"/>
+  <var>
+    <var-name>test</var-name>
+    <var-value>((heightInInches >= 60) or (*this* == null))</var-value>
+  </var>
+</field>
 ]]></source>
      <p>
      A few quick notes on the grammer.</p>
@@ -716,7 +733,7 @@
 
 <field property="password"
        depends="required,twofields">
-          <arg0 key="typeForm.password.displayname"/>
+          <arg position="0" key="typeForm.password.displayname"/>
           <var>
              <var-name>secondProperty</var-name>
              <var-value>password2</var-value>
@@ -817,7 +834,7 @@
 
 <field
     property="pregnancyTest" depends="requiredif">
-  <arg0 key="medicalStatusForm.pregnancyTest.label"/>
+  <arg position="0" key="medicalStatusForm.pregnancyTest.label"/>
   <var>
     <var-name>field[0]</var-name>
     <var-value>sex</var-value>
@@ -850,7 +867,7 @@
 
 <field
     property="testResult" depends="requiredif">
-  <arg0 key="medicalStatusForm.testResult.label"/>
+  <arg position="0" key="medicalStatusForm.testResult.label"/>
   <var>
     <var-name>field[0]</var-name>
     <var-value>pregnancyTest</var-value>
@@ -901,7 +918,7 @@
 <field
     property="firstName" indexedListProperty="dependents"
     depends="requiredif">
-  <arg0 key="dependentlistForm.firstName.label"/>
+  <arg position="0" key="dependentlistForm.firstName.label"/>
   <var>
     <var-name>field[0]</var-name>
     <var-value>lastName</var-value>
@@ -920,7 +937,7 @@
     property="dob"
     indexedListProperty="dependents"
     depends="requiredif,date">
-  <arg0 key="dependentlistForm.dob.label"/>
+  <arg position="0" key="dependentlistForm.dob.label"/>
   <var>
     <var-name>field[0]</var-name>
     <var-value>lastName</var-value>
@@ -939,7 +956,7 @@
     property="coverageType"
     indexedListProperty="dependents"
     depends="requiredif">
-  <arg0 key="dependentlistForm.coverageType.label"/>
+  <arg position="0" key="dependentlistForm.coverageType.label"/>
   <var>
     <var-name>field[0]</var-name>
     <var-value>lastName</var-value>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to