struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tur...@apache.org
Subject cvs commit: jakarta-struts/doc/userGuide dev_validator.xml
Date Thu, 20 Mar 2003 16:36:35 GMT
turner      2003/03/20 08:36:35

  Modified:    doc/faqs newbie.xml
               doc/userGuide dev_validator.xml
  Log:
  Added simpler example of using the requiredif validator test to dev_validator.xml,
  added faq on using requiredif to newbie.xml, also fixed syntax of more complicated
  example in dev_validator.xml to actually be correct (it was using things like
  fieldJoin instead of field-join.
  
  Revision  Changes    Path
  1.13      +63 -0     jakarta-struts/doc/faqs/newbie.xml
  
  Index: newbie.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/doc/faqs/newbie.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- newbie.xml	5 Feb 2003 04:23:20 -0000	1.12
  +++ newbie.xml	20 Mar 2003 16:36:34 -0000	1.13
  @@ -5,6 +5,7 @@
   <author>James Holmes</author>
   <author>Craig R. McClanahan</author>
   <author>Edgar Dollin</author>
  +<author>James Turner</author>
   <title>Newbie FAQ - Apache Struts</title>
   </properties>
   <body>
  @@ -110,6 +111,10 @@
       <a href="#prepopulate">How can I prepopulate a form?</a>
       </li>
   
  +    <li>
  +    <a href="#requiredif">Can you give me a simple example of using the requiredif
Validator rule?</a>
  +    </li>
  +
       </ul>
    
       <p>
  @@ -699,6 +704,64 @@
           instead of calling your processing action.</li>
       </ul>
   
  +</section>
  +
  +<section href="requiredif"
  +         name="Can you give me a simple example of using the requiredif Validator rule?">
  +     <p>Let's assume you have a medical information form with three fields, sex,
dateOfLastMamogram, and testResult.  
  +     If sex is 'f' or 'F', dateOfLastMamogram is required.  If dateOfLastMamogram is not
blank, testResult is required.
  +     The entry in your validation.xml file would look like this:
  +     </p>
  +     <pre>
  +&lt;form name="medicalStatusForm"&gt;
  +
  +&lt;field
  +    property="dateOfLastMamogram" depends="requiredif"&gt;
  +  &lt;arg0 key="medicalStatusForm.dateOfLastMamogram.label"/&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;sex&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;EQUAL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-value[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;F&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;sex&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;EQUAL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-value[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;f&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-join&lt;/var-name&gt;
  +    &lt;var-value&gt;OR&lt;/var-value&gt;
  +  &lt;/var&gt;
  +&lt;/field&gt;
  +
  +&lt;field
  +    property="testResult" depends="requiredif"&gt;
  +  &lt;arg0 key="medicalStatusForm.testResult.label"/&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;dateOfLastMamogram&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;NOTNULL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +&lt;/field&gt;
  +&lt;/form&gt;
  +</pre>
   </section>
   
   
  
  
  
  1.30      +68 -12    jakarta-struts/doc/userGuide/dev_validator.xml
  
  Index: dev_validator.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/doc/userGuide/dev_validator.xml,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- dev_validator.xml	19 Mar 2003 04:49:04 -0000	1.29
  +++ dev_validator.xml	20 Mar 2003 16:36:34 -0000	1.30
  @@ -502,8 +502,65 @@
       non-null and field Y equals 'male'".
       </p>
   
  +     <p>Let's assume you have a medical information form with three fields, sex,
dateOfLastMamogram, and testResult.  
  +     If sex is 'f' or 'F', dateOfLastMamogram is required.  If dateOfLastMamogram is not
blank, testResult is required.
  +     The entry in your validation.xml file would look like this:
  +     </p>
  +     <pre>
  +&lt;form name="medicalStatusForm"&gt;
  +
  +&lt;field
  +    property="dateOfLastMamogram" depends="requiredif"&gt;
  +  &lt;arg0 key="medicalStatusForm.dateOfLastMamogram.label"/&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;sex&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;EQUAL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-value[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;F&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;sex&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;EQUAL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-value[1]&lt;/var-name&gt;
  +    &lt;var-value&gt;f&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-join&lt;/var-name&gt;
  +    &lt;var-value&gt;OR&lt;/var-value&gt;
  +  &lt;/var&gt;
  +&lt;/field&gt;
  +
  +&lt;field
  +    property="testResult" depends="requiredif"&gt;
  +  &lt;arg0 key="medicalStatusForm.testResult.label"/&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;dateOfLastMamogram&lt;/var-value&gt;
  +  &lt;/var&gt;
  +  &lt;var&gt;
  +    &lt;var-name&gt;field-test[0]&lt;/var-name&gt;
  +    &lt;var-value&gt;NOTNULL&lt;/var-value&gt;
  +  &lt;/var&gt;
  +&lt;/field&gt;
  +&lt;/form&gt;
  +</pre>
  +   
  +     
  +
       <p>
  -    The syntax looks like this:
  +    Here's a more complex example using indexed properties.
       </p>
   
       <p>
  @@ -516,8 +573,7 @@
       type="org.apache.struts.webapp.validator.forms.ValidatorForm">
       <form-property
           name="dependents"
  -        type="org.apache.struts.webapp.validator.Dependent[]"
  -        initial="{'','','','','','','','','','',''}"/>
  +        type="org.apache.struts.webapp.validator.Dependent[]" size="10"/>
       <form-property
           name="insureDependents"
           type="java.lang.Boolean"
  @@ -547,11 +603,11 @@
       <var-value>lastName</var-value>
     </var>
     <var>
  -    <var-name>fieldIndexed[0]</var-name>
  +    <var-name>field-indexed[0]</var-name>
       <var-value>true</var-value>
     </var>
     <var>
  -    <var-name>fieldTest[0]</var-name>
  +    <var-name>field-test[0]</var-name>
       <var-value>NOTNULL</var-value>
     </var>
   </field>
  @@ -566,11 +622,11 @@
       <var-value>lastName</var-value>
     </var>
     <var>
  -    <var-name>fieldIndexed[0]</var-name>
  +    <var-name>field-indexed[0]</var-name>
       <var-value>true</var-value>
     </var>
     <var>
  -    <var-name>fieldTest[0]</var-name>
  +    <var-name>field-test[0]</var-name>
       <var-value>NOTNULL</var-value>
     </var>
   </field>
  @@ -585,11 +641,11 @@
       <var-value>lastName</var-value>
     </var>
     <var>
  -    <var-name>fieldIndexed[0]</var-name>
  +    <var-name>field-indexed[0]</var-name>
       <var-value>true</var-value>
     </var>
     <var>
  -    <var-name>fieldTest[0]</var-name>
  +    <var-name>field-test[0]</var-name>
       <var-value>NOTNULL</var-value>
     </var>
     <var>
  @@ -597,15 +653,15 @@
       <var-value>insureDependents</var-value>
     </var>
     <var>
  -    <var-name>fieldTest[1]</var-name>
  +    <var-name>field-test[1]</var-name>
       <var-value>EQUAL</var-value>
     </var>
     <var>
  -    <var-name>fieldValue[1]</var-name>
  +    <var-name>field-value[1]</var-name>
       <var-value>true</var-value>
     </var>
     <var>
  -    <var-name>fieldJoin</var-name>
  +    <var-name>field-join</var-name>
       <var-value>AND</var-value>
     </var>
   </field>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org


Mime
View raw message