[cvs] expresso/expresso-web/expresso/doc/edg validation.xml

JCorporate Ltd jcorp at jcorp2.servlets.net
Wed Aug 11 13:22:16 PDT 2004


Update of /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg
In directory jcorp2.servlets.net:/tmp/cvs-serv20467

Modified Files:
	validation.xml 
Log Message:
<Aucun commentaire entré>


Index: validation.xml
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/expresso/doc/edg/validation.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** validation.xml	9 Aug 2004 16:30:27 -0000	1.1
--- validation.xml	11 Aug 2004 20:22:13 -0000	1.2
***************
*** 247,275 ****
      <programlisting>    &lt;field property="customeremail" depends="email"&gt;
          &lt;arg0 key="customer.email"/&gt;
!     &lt;/field&gt;</programlisting> url - validates url format. Has four
!     optional variables (allowallschemes, allow2slashes, nofragments and
!     schemes) which can be used to configure this validator. allowallschemes
!     specifies whether all schemes are allowed. Valid values are true or false
!     (default is false). If this is set to true then the schemes variable is
!     ignored. allow2slashes specifies whether double '/' characters are
!     allowed. Valid values are true or false (default is false). nofragments
!     specifies whether fragements are allowed. Valid values are true or false
!     (default is false - i.e. fragments are allowed). schemes - use to specify
!     a comma separated list of valid schemes. If not specified then the
!     defaults are used which are http, https and ftp. <programlisting>    &lt;field property="custUrl" depends="url"&gt;
!         &lt;arg0 key="customer.url"/&gt;
!     &lt;/field&gt;
! 
!     &lt;field property="custUrl" depends="url"&gt;
!         &lt;arg0 key="customer.url"/&gt;
!         &lt;var&gt;
!            &lt;var-name&gt;nofragments&lt;/var-name&gt;
!            &lt;var-value&gt;true&lt;/var-value&gt;
!         &lt;/var&gt;
!         &lt;var&gt;
!            &lt;var-name&gt;schemes&lt;/var-name&gt;
!            &lt;var-value&gt;http,https,telnet,file&lt;/var-value&gt;
!         &lt;/var&gt;
!     &lt;/field&gt;</programlisting> </para>
    </sect1>
  
--- 247,251 ----
      <programlisting>    &lt;field property="customeremail" depends="email"&gt;
          &lt;arg0 key="customer.email"/&gt;
!     &lt;/field&gt;</programlisting></para>
    </sect1>
  
***************
*** 364,464 ****
      Now you’ll form will be validated following the rules you defined in
      validation.xml both, client-side and server-side</para>
-   </sect1>
- 
-   <sect1>
-     <title>Designing Complex Validations with valid when</title>
- 
-     <para>[Since Struts 1.2.0] A frequent requirement in validation design is
-     to validate one field against another (for example, if you have asked the
-     user to type in 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 validwhen validation
-     rule is designed to handle these cases. The validwhen rule takes a single
-     var field, called test. 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:<itemizedlist>
-         <listitem>
-           <para>Single or double-quoted string literals. </para>
-         </listitem>
- 
-         <listitem>
-           <para>Integer literals in decimal, hex or octal format </para>
-         </listitem>
- 
-         <listitem>
-           <para>The value null which will match against either null or an
-           empty string </para>
-         </listitem>
- 
-         <listitem>
-           <para>Other fields in the form referenced by field name, such as
-           customerAge</para>
-         </listitem>
- 
-         <listitem>
-           <para>Indexed fields in the form referenced by an explicit integer,
-           such as childLastName[2] </para>
-         </listitem>
- 
-         <listitem>
-           <para>Indexed fields in the form referenced by an implicit integer,
-           such as childLastName[], which will use the same index into the
-           array as the index of the field being tested. </para>
-         </listitem>
- 
-         <listitem>
-           <para>Properties of an indexed fields in the form referenced by an
-           explicit or implicit integer, such as child[].lastName, which will
-           use the same index into the array as the index of the field being
-           tested. </para>
-         </listitem>
- 
-         <listitem>
-           <para>The literal *this, which contains the value of the field
-           currently being tested</para>
-         </listitem>
-       </itemizedlist></para>
- 
-     <para>As an example of how this would work, consider a form with fields
-     sendNewsletter and emailAddress. The emailAddress field is only required
-     if the sendNewsletter field is not null. You could code this using the
-     validwhen rule as: <programlisting>  &lt;field depends="validwhen" property="emailAddress"&gt;
-     &lt;arg0 key="userinfo.emailAddress.label" /&gt;
-     &lt;var&gt;
-       &lt;var-name&gt;test&lt;/var-name&gt;
-       &lt;var-value&gt;((sendNewsletter == null) or (*this* != null))&lt;/var-value&gt;
-     &lt;/var&gt;
-   &lt;/field&gt;</programlisting>Which reads as: this field is valid if
-     sendNewsletter is null or the field value is not null. </para>
- 
-     <para></para>
- 
-     <para>Here's a slightly more complicated example using indexed fields.
-     Assume a form with a number of lines to allow the user to enter part
-     numbers and quantities they wish to order. An array of beans of class
-     orderLine is used to hold the entries in a property called orderLines. If
-     you wished to verify that every line with part number also had a quantity
-     entered, you could do it with:<programlisting>  &lt;field depends="validwhen" indexedListProperty="orderLines" property="quantity"&gt;
-     &lt;arg0 key="orderform.quantity.label" /&gt;
-     &lt;var&gt;
-       &lt;var-name&gt;test&lt;/var-name&gt;
-       &lt;var-value&gt;((orderLines[].partNumber == null) or (*this* != null))&lt;/var-value&gt;
-     &lt;/var&gt;
-   &lt;/field&gt;</programlisting>Which reads as: This field is value if the
-     corresponding partNumber field is null, or this field is not null. </para>
- 
-     <para> As a final example, imagine a form where the user must enter their
-     height in inches, and if they are under 60 inches in height, it is an
-     error to have checked off nbaPointGuard as a career. <programlisting>  &lt;field depends="validwhen" property="nbaPointGuard"&gt;
-     &lt;arg0 key="careers.nbaPointGuard.label" /&gt;
-     &lt;var&gt;
-       &lt;var-name&gt;test&lt;/var-name&gt;
-       &lt;var-value&gt;((heightInInches &amp;gt;= 60) or (*this* == null))&lt;/var-value&gt;
-     &lt;/var&gt;
-   &lt;/field&gt;</programlisting> <emphasis>A few quick notes on the grammer.
-     All comparisons must be enclosed in parens. Only two items may be joined
-     with and or or If both items to be compared are convertable to ints, a
-     numeric comparison is done, otherwise a string comparison is done.
-     </emphasis></para>
    </sect1>
  
--- 340,343 ----



More information about the cvs mailing list