cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject cvs commit: xml-cocoon2/webapp/docs/samples/formvalidation ERROR.xsp OK.xsp descriptor.xml
Date Tue, 10 Jul 2001 15:27:19 GMT
haul        01/07/10 08:27:17

  Modified:    xdocs    logicsheet-forms.xml
               webapp   sitemap.xmap
               webapp/docs/samples samples.xml
  Added:       webapp/docs/samples/formvalidation ERROR.xsp OK.xsp
                        descriptor.xml
  Log:
  examples for formvalidation, documentation fixes
  
  Revision  Changes    Path
  1.2       +11 -6     xml-cocoon2/xdocs/logicsheet-forms.xml
  
  Index: logicsheet-forms.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/xdocs/logicsheet-forms.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- logicsheet-forms.xml	2001/06/19 11:45:37	1.1
  +++ logicsheet-forms.xml	2001/07/10 15:26:49	1.2
  @@ -41,11 +41,11 @@
   <?xml version="1.0"?>
   <root>
   
  -   <parameter name="persons" type="long" min="1" default="4"/>
  -   <parameter name="deposit" type="double" min="10.0" max="999.99" nullable="no"/>
  -   <parameter name="email" type="string" max-len="50" match-regex="^[\d\w][\d\w\-_\.]*@([\d\w\-_]+\.)\w\w\w?$">
  +   <parameter name="persons" type="long" min="1" default="4" nullable="no"/>
  +   <parameter name="deposit" type="double" min="10.0" max="999.99"/>
  +   <parameter name="email" type="string" max-len="50" matches-regex="^[\d\w][\d\w\-_\.]*@([\d\w\-_]+\.)\w\w\w?$">
   
  -   <constraint-set name="car-reservation">
  +   <constraint-set name="car-reservation"/>
          <validate name="persons"/>
          <validate name="deposit" min="50.0"/>
          <validate name="email"/>
  @@ -153,8 +153,13 @@
   						   request attribute </td></tr>
   	 </table>
        <p>
  -     If you'd like to be more specific what went wrong, you can query
  -     the descriptor file for attributes.
  +     For debugging purposes or if you would like to iterate over the
  +     validation results, <code>xsp-formval:results</code> returns a
  +     <code>java.util.Map</code> containing them all.
  +     </p>
  +     <p>
  +     If you would like to be more specific what went wrong, you can
  +     query the descriptor file for attributes.
        </p>
        <p>
        First set the url of the file or resource that contains the
  
  
  
  1.23      +23 -0     xml-cocoon2/webapp/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/sitemap.xmap,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- sitemap.xmap	2001/07/10 12:34:20	1.22
  +++ sitemap.xmap	2001/07/10 15:26:59	1.23
  @@ -101,6 +101,7 @@
      <map:action name="lang-select" src="org.apache.cocoon.acting.LangSelect"/>
      <map:action name="locale" src="org.apache.cocoon.acting.LocaleAction"/>
      <map:action name="request" src="org.apache.cocoon.acting.RequestParamAction"/>
  +   <map:action name="form-validator" src="org.apache.cocoon.acting.FormValidatorAction"/>
     </map:actions>
   
    </map:components>
  @@ -130,6 +131,14 @@
      <map:transform src="stylesheets/slides/slides-apachecon.xsl"/>
      <map:serialize/>
     </map:resource>
  +
  +  <map:resource name="dynamic-page">
  +     <map:generate type="serverpages" src="{target}.xsp"/>
  +     <map:transform src="stylesheets/dynamic-page2html.xsl">
  +       <map:parameter name="view-source" value="{target}.xsp"/>
  +     </map:transform>
  +     <map:serialize/>
  +  </map:resource>
    </map:resources>
   
   <!-- ========================== Action sets ================================ -->
  @@ -402,6 +411,19 @@
        <map:serialize/>
      </map:match>
   
  +   <!-- ======================= FormValidation ============================= -->
  +
  +   <map:match pattern="formvalidation/test">
  +     <map:act type="form-validator">
  +        <map:parameter name="descriptor" value="context:///docs/samples/formvalidation/descriptor.xml"/>
  +        <map:parameter name="validate-set" value="car-reservation"/>
  +	<map:redirect-to resource="dynamic-page" target="docs/samples/formvalidation/OK"/>
  +     </map:act>
  +      <map:redirect-to resource="dynamic-page" target="docs/samples/formvalidation/ERROR"/>
  +   </map:match>
  +
  +
  +
      <!-- ========================== Session ================================= -->
      <map:match pattern="session">
       <map:redirect-to uri="session/sessionpage.xsp"/>
  @@ -414,6 +436,7 @@
        </map:transform>
        <map:serialize/>
      </map:match>
  +
   
      <!-- ========================== Stream ================================= -->
      <map:match pattern="request1">
  
  
  
  1.5       +4 -0      xml-cocoon2/webapp/docs/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/docs/samples/samples.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- samples.xml	2001/07/06 21:35:05	1.4
  +++ samples.xml	2001/07/10 15:27:06	1.5
  @@ -141,6 +141,10 @@
         that you have a database and table according to the docs/samples/sql/sql-page.xml.sql
         definitions.  Don't forget to change the driver information...
       </sample>
  +    <sample name="Form Validation" href="formvalidation/test" xlink:role="dynamic">
  +      This example demonstrates the use of an action to validate user
  +      input and report validation errors to the user through a taglib.
  +    </sample>
     </group>
   
     <group name="System Pages">
  
  
  
  1.1                  xml-cocoon2/webapp/docs/samples/formvalidation/ERROR.xsp
  
  Index: ERROR.xsp
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?><!-- -*- sgml -*- -->
  <xsp:page
     language="java"
     xmlns:xsp="http://apache.org/xsp"
     xmlns:xsp-formval="http://apache.org/xsp/form-validator/2.0"
     xmlns:xsp-request="http://apache.org/xsp/request/2.0"
  >
  
     <page>
  
        <title>Car Reservation</title>
        <content>
  
        <para>
           Informal validation results <xsp:expr><xsp-formval:results/></xsp:expr>
        </para>
  
         <form action="test" method="POST">
         <!-- use this to get a clue if the user had a chance to fill in
              any date already -->
         <input type="hidden" name="visited" value="true"/>
         <xsp:logic>
            boolean userHasSeenForm = (<xsp-request:get-parameter name="visited"/>!=null);
         </xsp:logic>
        <para>
  	  How many persons should the car seat? 
  	  <input type="TEXT" name="persons" size="2">
  	     <xsp:attribute name="value"><xsp-request:get-parameter name="persons" default=""/></xsp:attribute>
  	  </input>
  	  <xsp-formval:descriptor name="context:///docs/samples/formvalidation/descriptor.xml"
constraint-set="car-reservation">
  	     <xsp:logic>
  	         if (userHasSeenForm) {
  		   if (<xsp-formval:is-toosmall name="persons"/> ) {
  		 	<b> The smallest available car seats <xsp-formval:get-attribute parameter="persons"
name="min"/></b>
  	           } else if ( <xsp-formval:is-toolarge name="persons"/> ) {
  		 	<b> The largest available car seats <xsp-formval:get-attribute parameter="persons"
name="max"/></b>
  	           } else if (<xsp-formval:is-error name="persons"/> ) {
  		 	<b> Some error occured. Your input is not correct. </b>
                     };
  		 };
  	     </xsp:logic>
  	  </xsp-formval:descriptor>
        </para>
  
  	  <xsp-formval:descriptor name="context:///docs/samples/formvalidation/descriptor.xml"
constraint-set="car-reservation">
        <para>
  	     <xsp-formval:validate name="deposit">
  	     	Please enter your deposit EUR 
  		<input type="TEXT" name="deposit" size="10">
  		  <xsp:attribute
  		  name="value"><xsp-request:get-parameter name="deposit" default=""/></xsp:attribute>
  		</input>
  		<xsp:logic>
  	         if (userHasSeenForm) {
  		    if ( <xsp-formval:is-null/>) {
  		 	 <b> You need to specify a deposit </b>
  	            } else if ( <xsp-formval:is-toosmall/> ) {
  		 	 <b> The deposit has to be at least EUR <xsp-formval:get-attribute name="min"/></b>
  	            } else if ( <xsp-formval:is-toolarge/> ) {
  		 	 <b> The deposit has to be at most EUR <xsp-formval:get-attribute name="max"/></b>
  	            } else if (<xsp-formval:is-notpresent/> ) {
  		 	 <b></b>
  	            } else if ( <xsp-formval:is-error/>) {
  		 	 <b> Some error occured. Your input is not correct. </b>
                      };
  		 };
  	     </xsp:logic>
  	     </xsp-formval:validate><br/>
        </para>
  
        <para>
  	     <xsp-formval:validate name="email">
  	     	Please enter your email
  		<input type="TEXT" name="email" size="50">
  		  <xsp:attribute
  		  name="value"><xsp-request:get-parameter name="email" default=""/></xsp:attribute>
  		</input>
  
  		<xsp:logic>
  	         if (userHasSeenForm) {
  		    if ( <xsp-formval:is-nomatch/> ) {
  		 	 <b> This does not seem to be a valid email
  		    address. Expected <pre><xsp-formval:get-attribute
  		    parameter="email" name="matches-regex"/></pre></b>
  	            } else if ( <xsp-formval:is-toolarge/> ) {
  		 	 <b> Only addresses with up to <xsp-formval:get-attribute parameter="email"
name="max-len"/> characters are accepted</b>
  	            } else if (<xsp-formval:is-notpresent/> ) {
  		 	 <b></b>
  	            } else if ( <xsp-formval:is-error/>) {
  		 	 <b> Some error occured. Your input is not correct. </b>
                      };
                    };
  	     </xsp:logic>
  	     </xsp-formval:validate><br/>
        </para>
  	     
  	  </xsp-formval:descriptor>
  	  <input type="submit" name="submit" value="submit"/>
        </form>
  
        </content>
     </page>
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/webapp/docs/samples/formvalidation/OK.xsp
  
  Index: OK.xsp
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?><!-- -*- sgml -*- -->
  <xsp:page
     language="java"
     xmlns:xsp="http://apache.org/xsp"
     xmlns:xsp-formval="http://apache.org/xsp/form-validator/2.0"
     xmlns:xsp-request="http://apache.org/xsp/request/2.0"
  >
  
     <page>
        <title>Car Reservation</title>
        <content>
  
        <para>You've successfully reserved a car for
        <b><xsp-request:get-parameter name="persons"/></b> with a deposit
of
        <b>EUR <xsp-request:get-parameter name="deposit"/></b>.</para>

  
        <para> Details will be sent to your e-mail address
        <tt><xsp-request:get-parameter name="email"/></tt></para>
  
        <para>You can make a new reservation <a href="test">here</a></para>
  
        </content>
     </page>
  </xsp:page>
  
  
  
  1.1                  xml-cocoon2/webapp/docs/samples/formvalidation/descriptor.xml
  
  Index: descriptor.xml
  ===================================================================
  <?xml version="1.0"?>
  <root>
  
     <parameter name="persons" type="long" min="2" default="9" nullable="yes"/>
     <parameter name="deposit" type="double" min="10.0" max="999.99"/>
     <parameter name="email" type="string" max-len="50" matches-regex="^[\d\w][\d\w\-_\.]*@([\d\w\-_]+\.)\w\w\w?$"/>
  
     <constraint-set name="car-reservation">
         <validate name="persons"/>
         <validate name="deposit" min="50.0"/>
         <validate name="email"/>
      </constraint-set>
  
  </root>
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message