home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / ERROR.xsp < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  8.3 KB  |  229 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <xsp:page language="java"
  19.           xmlns:xsp="http://apache.org/xsp"
  20.           xmlns:xsp-formval="http://apache.org/xsp/form-validator/2.0"
  21.           xmlns:xsp-request="http://apache.org/xsp/request/2.0">
  22.  
  23.    <page>
  24.  
  25.     <resources>
  26.        <resource type="file" href="descriptor.xml?cocoon-view=pretty-content">Descriptor</resource>
  27.        <resource type="doc" href="userdocs/xsp/logicsheet-forms.html">Action & Logicsheet</resource>
  28.     </resources>
  29.  
  30.     <title>Car Reservation</title>
  31.     <content>
  32.  
  33.     <para>
  34.        Informal validation results <xsp:expr><xsp-formval:results/></xsp:expr>
  35.     </para>
  36.  
  37.     <form method="POST">
  38.      <!-- use this to get a clue if the user had a chance to fill in
  39.           any date already. This is necessary if no validation results should be
  40.           displayed when the user first encounters the form. If the error messages
  41.           should be used to guide the user from the beginning, this is not needed.
  42.       -->
  43.      <input type="hidden" name="visited" value="true"/>
  44.      <xsp:logic>
  45.         boolean userHasSeenForm = (<xsp-request:get-parameter name="visited"/>!=null);
  46.      </xsp:logic>
  47.  
  48.  
  49.  
  50.      <!-- if validation constraints should be included in the error messages, a
  51.           reference to the file containing the validation rules is needed. Otherwise
  52.           it can be removed.
  53.      -->
  54.      <xsp-formval:descriptor name="descriptor.xml" constraint-set="car-reservation">
  55.  
  56.       <table>
  57.        <tbody>
  58.  
  59.         <!-- the first example field illustrates the simplest usage, passing the current
  60.              validation field name every time.
  61.         -->
  62.         <tr>
  63.          <td>How many persons should the car seat?</td>
  64.          <td>
  65.           <input type="TEXT" name="persons" size="2">
  66.            <xsp:attribute name="value"><xsp-request:get-parameter name="persons" default=""/></xsp:attribute>
  67.           </input>
  68.          </td>
  69.          <td>
  70.           <xsp:logic>
  71.             if (userHasSeenForm) {
  72.               if (<xsp-formval:is-toosmall name="persons"/> ) {
  73.                  <b> The smallest available car seats <xsp-formval:get-attribute parameter="persons" name="min"/></b>
  74.               } else if ( <xsp-formval:is-toolarge name="persons"/> ) {
  75.                  <b> The largest available car seats <xsp-formval:get-attribute parameter="persons" name="max"/></b>
  76.               } else if (<xsp-formval:is-error name="persons"/> ) {
  77.                  <b> Some error occured. Your input is not correct. </b>
  78.               }
  79.             }
  80.           </xsp:logic>
  81.          </td>
  82.         </tr>
  83.  
  84.  
  85.         <!-- another possibility is to create a context that is used for all nested 
  86.              validation tags. Note that here no validation parameter name is added to
  87.              the validation tags.
  88.         -->
  89.         <xsp-formval:validate name="deposit">
  90.          <tr>
  91.           <td>Please enter your deposit EUR</td>
  92.           <td>
  93.            <input type="TEXT" name="deposit" size="10">
  94.             <xsp:attribute name="value"><xsp-request:get-parameter name="deposit" default=""/></xsp:attribute>
  95.            </input>
  96.           </td>
  97.           <td>
  98.            <xsp:logic>
  99.             if (userHasSeenForm) {
  100.               if ( <xsp-formval:is-null/>) {
  101.                  <b> You need to specify a deposit </b>
  102.               } else if ( <xsp-formval:is-toosmall/> ) {
  103.                  <b> The deposit has to be at least EUR <xsp-formval:get-attribute name="min"/></b>
  104.               } else if ( <xsp-formval:is-toolarge/> ) {
  105.                  <b> The deposit has to be at most EUR <xsp-formval:get-attribute name="max"/></b>
  106.               } else if (<xsp-formval:is-notpresent/> ) {
  107.                  <b></b>
  108.               } else if ( <xsp-formval:is-error/>) {
  109.                  <b> Some error occured. Your input is not correct. </b>
  110.               }
  111.             }
  112.            </xsp:logic>
  113.           </td>
  114.          </tr>
  115.         </xsp-formval:validate>
  116.  
  117.         <xsp-formval:validate name="email">
  118.          <tr>
  119.           <td>Please enter your email</td>
  120.           <td>
  121.            <input type="TEXT" name="email" size="50">
  122.             <xsp:attribute name="value"><xsp-request:get-parameter name="email" default=""/></xsp:attribute>
  123.            </input>
  124.           </td>
  125.           <td>
  126.            <xsp:logic>
  127.             if (userHasSeenForm) {
  128.                if ( <xsp-formval:is-null/>) {
  129.                   <b> You need to specify an email </b>
  130.                } else if ( <xsp-formval:is-nomatch/> ) {
  131.                   <b> This does not seem to be a valid email
  132.                       address. Expected 
  133.                       <pre><xsp-formval:get-attribute parameter="email" name="matches-regex"/></pre>
  134.                   </b>
  135.                } else if ( <xsp-formval:is-toolarge/> ) {
  136.                   <b> Only addresses with up to 
  137.                       <xsp-formval:get-attribute parameter="email" name="max-len"/> 
  138.                       characters are accepted
  139.                   </b>
  140.                } else if (<xsp-formval:is-notpresent/> ) {
  141.                   <b></b>
  142.                } else if ( <xsp-formval:is-error/>) {
  143.                   <b> Some error occured. Your input is not correct. </b>
  144.                }
  145.             }
  146.            </xsp:logic>
  147.           </td>
  148.          </tr>
  149.         </xsp-formval:validate>
  150.  
  151.  
  152.         <!-- less embedded java is needed when using the <xsp-formval:on-XXX/> tags. They are
  153.              equivalent to the above "<xsp:logic>if (<xsp-formval:is-XXX/>) { ... } </xsp:logic>"
  154.              but much cleaner. 
  155.         -->
  156.         <xsp-formval:validate name="address">
  157.          <tr>
  158.           <td>Please enter the billing address</td>
  159.           <td>
  160.            <textarea rows="6" cols="40" name="address"><xsp-request:get-parameter name="address" default=""/></textarea>
  161.           </td>
  162.           <td>
  163.            <xsp:logic>
  164.             if (userHasSeenForm) {
  165.                <xsp-formval:on-null>
  166.                  <b> You need to specify an address. </b>
  167.                </xsp-formval:on-null>
  168.  
  169.                <xsp-formval:on-toolarge>
  170.                  <b> Only addresses with up to 
  171.                      <xsp-formval:get-attribute parameter="address" name="max-len"/> 
  172.                      characters are accepted.
  173.                  </b>
  174.                </xsp-formval:on-toolarge>
  175.  
  176.                <xsp-formval:on-notpresent/>
  177.             
  178.                <xsp-formval:on-error>
  179.                  <b> Some error occured. Your input is not correct. </b>
  180.                </xsp-formval:on-error>
  181.             }
  182.            </xsp:logic>
  183.           </td>
  184.          </tr>
  185.         </xsp-formval:validate>
  186.  
  187.  
  188.         <xsp-formval:validate name="type">
  189.          <tr>
  190.           <td>Please enter the type of car you would like to reserve</td>
  191.           <td>
  192.            <input type="text" name="type" size="10">
  193.               <xsp:attribute name="value"><xsp-request:get-parameter name="type" default=""/></xsp:attribute>
  194.            </input>
  195.           </td>
  196.           <td>
  197.            <xsp:logic>
  198.             if (userHasSeenForm) {
  199.                <xsp-formval:on-null>
  200.                  <b> You need to specify a type: cabrio, sedan, station, racing. </b>
  201.                </xsp-formval:on-null>
  202.  
  203.                <xsp-formval:on-nomatch>
  204.                  <b> Only <xsp-formval:get-attribute parameter="type" name="one-of"/> 
  205.                      are accepted.
  206.                  </b>
  207.                </xsp-formval:on-nomatch>
  208.  
  209.                <xsp-formval:on-notpresent/>
  210.             
  211.                <xsp-formval:on-error>
  212.                  <b> Some error occured. Your input is not correct. </b>
  213.                </xsp-formval:on-error>
  214.             }
  215.            </xsp:logic>
  216.           </td>
  217.          </tr>
  218.         </xsp-formval:validate>
  219.        </tbody>
  220.       </table>
  221.          
  222.      </xsp-formval:descriptor>
  223.      <input type="submit" name="submit" value="submit"/>
  224.     </form>
  225.  
  226.    </content>
  227.   </page>
  228. </xsp:page>
  229.