You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de> on 2001/06/12 18:32:27 UTC

Re: [C2] actions, forms, etc.

Well, it's been a while since this thread came up....

Sorry for not CCing this mail to all involved authors but this is
rather long and it touches several classes.

  I. Introduction
 II. Contents of the attached archive
III. Notes on the patch
 IV. Usage


I. Introduction

Currently FormValidatiorAction only returns null if validation fails
leaving it for the application (xsp) to figure out what went wrong.

This is where this patch comes in.

This patch enables FormValidatorAction to communicate to the
application a more verbose error status through an request
attribute. In addition a new taglib allows easy access to the
results. On top of that this taglib gives access to the attributes for
parameters declared in those section in descriptor.xml relevant to the
validation process.


II. Contents of the attached archive

The attached archive contains a patch plus a number of new classes, a
new taglib, and a new jar-File. 

This new jar -- enumeration.jar was created from a compiled version of
an enumeration factory class available at
http://home.t-online.de/home/Christ-Usch.Grein/Java/EnumFact.html I
think the licence is compatible so it can be included.


III. Notes on the patch

The patch is done against 2.1-dev.

Since this adds a number of new classes I wasn't sure where to put
them. I think most are placed suitably right, one class
"org.apache.cocoon.acting.ConfigurationHelper" however might need to
be moved. This class was introduced because I feel descriptor files
should be reloaded when they change. Because I borrowed code from
org.apache.cocoon.acting.AbstractComplimentaryConfigurableAction to
load and cache configurations and modified it so that reloads can
occur I placed it where it is currently. 

I think AbstractComplimentaryConfigurableAction should be modified
accordingly to facilitate reloading as well. (Haven't done that
yet. Comments?)

I used the enumeration factory mentioned above because I strongly
believe that enumerations are superior to coding the values to ints
bearing implicit semantics. I hope it's OK.

Another thing might be that AbstractValidatorAction and
FormValidatorAction could communicate the error code by exceptions. As
I believe the error code is part of the result I coded it as return
value rather than an exception. In addition this return code is also
needed for communication with the XSP thus adding to this impression.

In AbstractValidatorAction I needed to introduce some methods that I
believe would be better suited within the Avalon API. These are
getAttributeAsLong returning java.lang.Long and getAttributeAsDouble
returning java.lang.Double. Avalon provides only getAttributeAsFloat
but not Double. Unfortunately AbstractFormValidator is designed to
handle Doubles. In addition I found that returning and taking as
arguments Objects is more convinient as it is easier to figure out if
the attribute is present. (OK could have used the one without default
and cought the exception. I believe the code is cleaner this way
though.)



IV. Usage

1) Modified FormValidatorAction
   Behaves as before. Only change is that it used to bail out on the
   first invalid parameter while now it validates all.

2) xsp-formval Taglib
   a) declare its name space xmls:xsp-formval="http://apache.org/xsp/form-validator/2.0"
   b) if only interested in validation results, just 

	     <xsp:logic>
		 if (<xsp-formval:is-ok name="input"/>) {
		      <xsp:content> (OK) </xsp:content>
	         } else {
		      <xsp:content> (ERROR) </xsp:content>
                 };
	     </xsp:logic>

      Bear in mind though, that the result is communicated through
      request attributes. These are discarded whenever a new request
      object is created. This happens for example when using
      redirections within the sitemap....

   c) if you'd like to be more specific what went wrong, you could
      query the descriptor file for attributes

	  <!-- first set the url of the file or resource that contains
	       the parameter descriptions and constraint sets.
	       This needs to be an ancestor to all other tags (of this
	       taglib). Multiple use of this tag is allowed (although
	       probably not necessary).
	       
	       You need to do this only if you plan to query the
	       descriptor file or if you'd like to use the shorthand
	       below. 
	  -->
	  <xsp-formval:descriptor name="descriptor.xml" constraint-set="user-input">
	     this parameter must be at least <xsp-formval:get-attribute parameter="input" name="min"/>
	  </xsp-formval:descriptor>
   
   d) if you need to use one parameter a lot, there's a short hand

	  <xsp-formval:descriptor name="descriptor.xml" constraint-set="user-input">
	     <!-- work on parameter named "input2". Use this e.g. if
		  you'd like to set up the properties of an input tag
		  according to the information from the descriptor
		  file or if you'd like to give detailed error
		  messages.

		  Note that you can specify additional attributes in
		  the description file that are not understood (and
		  therefore ignored) by the FormValidatorAction but
		  that could be queried here. This might be e.g. the
		  size of the input field which might be different
		  from the max-len a parameter can take.
	     -->		  
	     <xsp-formval:validate name="input2">
	     <xsp:logic>
		 if (<xsp-formval:is-ok/>) {
		      <xsp:content> (OK) </xsp:content>
		 } else if ( <xsp-formval:is-toosmall/> ) {
		      <xsp:content> (zu klein (&lt; <xsp-formval:get-attribute name="min"/>))</xsp:content>
	         } else if ( <xsp-formval:is-toolarge/> ) {
		      <xsp:content> (zu groß (&gt; <xsp-formval:get-attribute name="max"/>))</xsp:content>
	         } else {
		      <xsp:content> (ERROR) </xsp:content>
                 };
	     </xsp:logic>
	     </xsp-formval:validate>
	  </xsp-formval:descriptor>

I'd be delighted if this could make it into the CVS.

Enjoy. Feedback welcome.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Re: [C2] actions, forms, etc.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
Davanum,

On 19.Jun.2001 -- 05:19 AM, Davanum Srinivas wrote:
> 1. Checked in your docs. Please take a look.

fine.

> 2. XSP should be working now.

indeed, no problem here anymore.

> 3. Did you try using "context:///" (note the extra '/') instead of context://. If this does not
> work, please let me know.

Yes, I had a problem using it from a sub sitemap. I have been
reluctant to report that problem and well, it has been fixed anyway :-) 

Attached you find a sample for the form validation taglib. New files
are in the archive, changes in the patch.

In addition the patch fixes some minor glitches I caused last time and
adds a tag to xsp-formval to retrieve all validation results in a
java.util.Map.

More noteworthy is, that it also patches
AbstractComplementaryConfigurableAction in a way that configuration
files are reread when they change. This is done exactly like it was
done in XSPFormValidatorHelper by using the Source and
ConfigurationHelper Classes. I have suggested this a while back and no
one commented it, so I reckon it's OK to do so :-)

This entails a API change, since
AbstractCom....Action.getConfiguration now takes an additional
argument, whether reloads should occur or not. This is controlled by a
new parameter "<map:parameter name="reloadable" value="true"/>" for
each invocation of an action in the sitemap. Consequently, all Actions
that call getConfiguration are patched as well.

To keep compatible an additional method is there with the old
signature that calls the modified method with reloadable=true.

You might want to either remove that method or not modify the other
actions. Of course you could also apply the patch as is :-)

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Re: [C2] actions, forms, etc.

Posted by giacomo <gi...@apache.org>.
On Tue, 19 Jun 2001, Davanum Srinivas wrote:

> Christian,
>
> Thanks a ton.
>
> 1. Checked in your docs. Please take a look.
> 2. XSP should be working now.
> 3. Did you try using "context:///" (note the extra '/') instead of context://. If this does not
> work, please let me know.

We need to fix that down as we all agreed that it must be
context://blabla instead of the now needed context:///blabla

Does anyone has some free cycles to fix it?

Giacomo

>
> If all's well, please submit your sample.
>
> Thanks,
> dims
>
> --- Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de> wrote:
> > On 15.Jun.2001 -- 04:34 AM, Davanum Srinivas wrote:
> > > Also, It will be *REALLY* helpful if you could submit a sample that shows off how to use the
> > > LogicSheet and actions. Finally Please consider submitting some documentation similar to the
> > ones
> > > in xdocs directory to make it easy for people to make use of your contribution. FYI, You can
> > use
> > > "build docs" to build the documentation.
> >
> > Davanum,
> >
> > the attached file is the reworked documentation from the patch
> > accompanying mail. I have not provided entries for docs-book.xml or
> > site-book.xml since I was unsure about where to put it.
> >
> > Would be quite nice if there would be some guide line for
> > docs eg. what documents qualify as "overview" and what as
> > "technical".
> >
> > An example is not included because
> > a) xsp seems to be broken right now (CVS monday)
> > b) I'm still not able to use context:// in a sub-sitemap. The file is
> >    always searched for in $COCOON_DIR
> >
> > 	Chris.
> >
> > --
> > C h r i s t i a n       H a u l
> > haul@informatik.tu-darmstadt.de
> >     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
> > > <?xml version="1.0"?>
> > <!DOCTYPE document SYSTEM "dtd/document-v10.dtd">
> > <document>
> >   <header>
> > 	 <title>Using Form Validation</title>
> > 	 <version>0.1</version>
> > 	 <type>Overview document</type>
> > 	 <authors>
> >            <person name="Christian Haul" email="haul@informatik.tu-darmstadt.de"/>
> > 	 </authors>
> >   </header>
> >   <body>
> >    <s1 title="Introduction?">
> >    <p>
> >    For most web applicatipns input is essential. Cocoon provides a
> >    variety of modules to support basic interaction like simple syntax
> >    checking of input data or writing input data to databases.
> >    </p>
> >    <p>
> >    This is about sntax checking. See
> >    org.apache.cocoon.acting.DatabaseAbstractAction (in javadocs) for
> >    details on database interaction.
> >    </p>
> >     <p>
> >     FormValidatorAction communicates to the application a verbose
> >     error status through an request attribute. In addition a taglib
> >     allows easy access to the results. On top of that this taglib
> >     gives access to the attributes for parameters declared in those
> >     sections in descriptor.xml relevant to the validation process.
> >     </p>
> >     <s2 title="The Descriptor File">
> >     <p>
> >     For details on the syntax of the descriptor file see
> >     javadocs. Basically it constists of two sections, a list of
> >     parameters and their properties and a list of constraints or
> >     constraint sets. The file syntax is set up so that it can be
> >     shared with the database actions.
> >     </p>
> >      <source>
> > <![CDATA[
> > <?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?$">
> >
> >    <constraint-set name="car-reservation">
> >        <validate name="persons"/>
> >        <validate name="deposit" min="50.0"/>
> >        <validate name="email"/>
> >     </constraint-set>
> >
> > </root>
> > ]]>
> >      </source>
> >     <p>
> >     The aboce could for example describe expected input from a reservation
> >     form. Specifications in a constraint set take preceedence over
> >     the general ones.
> >     </p>
> >     </s2>
> >     <s2 title="Sitemap Usage">
> >     <p>
> >     To take advantage of the form validator action create two
> >     pages. One for the input form and one indicating the acceptance of
> >     the reservation. Create a pipeline in your sitemap so that the
> >     confirmation page is only shown when the action completed
> >     successfully and the input form is returned otherwise.
> >     </p>
> >      <source>
> > <![CDATA[
> > <?xml version="1.0"?>
> >    <map:match pattern="car-reservation">
> >      <map:act type="form-validator">
> >         <!-- add you favourite database action here -->
> >         <map:parameter name="descriptor" value="descriptor.xml"/>
> >         <map:parameter name="validate-set" value="car-reservation"/>
> > 	<map:generate type="serverpages" src="OK.xsp"/>
> > 	<map:transform src="stylesheets/dynamic-page2html.xsl"/>
> > 	<map:serialize/>
> >      </map:act>
> >      <map:generate type="serverpages" src="test/ERROR.xsp"/>
> >      <map:transform src="stylesheets/dynamic-page2html.xsl"/>
> >      <map:serialize/>
> >    </map:match>
> > ]]>
> >      </source>
> >      <p>
> >      Note here that you may not use a redirection to point to the
> >      pages if you would like to access the validation results e.g. on
> >      the error page. A redirection would create a new request object
> >      and thus discard the validation results.
> >      </p>
> >     </s2>
> >     <s2 title="XSP Usage">
> >     <p>
> >     To give the user some feedback why her/his submitted data was rejected
> >     there is a special taglib "xsp-formval". Declare its name space as
> >     usual.
> >     </p>
> >     <p>
> >     If only interested in validation results, just
> >     </p>
> >      <source>
> > <![CDATA[
> >      <xsp:logic>
> > 	 if (!<xsp-formval:is-ok name="persons"/>) {
> > 	      <myapp:error>(ERROR)</myapp:error>
> >          };
> >      </xsp:logic>
> > ]]>
> >      </source>
> >      <p>
> >      Internationalization issues are a separate concern and are not
> >      discussed here.
> >      </p>
> >      <p>
> >      Currently the following validation result codes are supported:
> >      </p>
> > 	 <table>
> > 	 <tr><th>tag</th><th>Meaning</th></tr>
> > 	 <tr><td>xsp-formval:is-ok</td><td>no error occurred,
> > 	                                   parameter successfully
> > 					   checked</td></tr>
> > 	 <tr><td>xsp-formval:is-error</td><td>some error occurred,
> > 	                                      this is a result that
> > 					      is never set but serves
> > 					      as a comparison target
> > 					   </td></tr>
> > 	 <tr><td>xsp-formval:is-null</td><td>the parameter is null but
> > 	                                     isn't allowed to</td></tr>
> > 	 <tr><td>xsp-formval:is-toosmall</td><td>either value or
> > 	                                        length in case of a
> > 						string is less than
> > 						the specified
> > 						minimum</td></tr>
> > 	 <tr><td>xsp-formval:is-toolarge</td><td>either value or
> > 	                                         length in case of a
> > 						 string is greater
> > 						 than the specified
> > 						 maximum</td></tr>
> > 	 <tr><td>xsp-formval:is-nomatch</td><td>a string parameter's
> > 	                                        value is not matched
> > 						by the specified
> > 						regular expression</td></tr>
> > 	 <tr><td>xsp-formval:is-notpresent</td><td>this is returned
> > 	                                           when the result of
> > 	                                           a validation is
> > 						   requested but no
> > 						   such result is
> > 						   found in the
> > 						   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.
> >      </p>
> >      <p>
> >      First set the url of the file or resource that contains the
> >      parameter descriptions and constraint sets.  This needs to be an
> >      ancestor to all other tags (of this taglib). Multiple use of this
> >      tag is allowed (although probably not necessary).
> >      </p>
> >      <p>
> >      You need to do this only if you plan to query the
> >      descriptor file or if you'd like to use the shorthand
> >      below.
> >      </p>
> >      <source>
> > <![CDATA[
> >   <xsp-formval:descriptor name="descriptor.xml" constraint-set="reservation">
> >      deposit must be at least EUR <xsp-formval:get-attribute parameter="deposit" name="min"/>
> >   </xsp-formval:descriptor>
> > ]]>
> >      </source>
> >      <p>
> >      If you need to use one parameter a lot, there's a short hand. Use
> >      this e.g. if you'd like to set up the properties of an input tag
> >      according to the information from the descriptor file or if you'd
> >      like to give detailed error messages.
> >      </p>
> >      <p>
> >      Note that you can specify additional attributes in the
> >      description file that are not understood (and therefore ignored)
> >      by the FormValidatorAction but that could be queried here. This
> >      might be e.g. the size of the input field which might be
> >      different from the max-len a parameter can take.
> >      </p>
> >      <source>
> > <![CDATA[
> >   <xsp-formval:descriptor name="descriptor.xml" constraint-set="car-reservation">
> >      <xsp-formval:validate name="deposit">
> >      <xsp:logic>
> > 	 if (<xsp-formval:is-null/>) {
> > 	      <myapp:error> (you must specify a deposit)) </myapp:error>
> > 	 } else if ( <xsp-formval:is-toosmall/> ) {
> > 	      <myapp:error> (deposit is too small (&lt; <xsp-formval:get-attribute
> > name="min"/>))</myapp:error>
> >          } else if ( <xsp-formval:is-toolarge/> ) {
> >
> === message truncated ===> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > For additional commands, email: cocoon-dev-help@xml.apache.org
>
>
> =====
> Davanum Srinivas, JNI-FAQ Manager
> http://www.jGuru.com/faq/JNI
>
> __________________________________________________
> Do You Yahoo!?
> Spot the hottest trends in music, movies, and more.
> http://buzz.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by Davanum Srinivas <di...@yahoo.com>.
Christian,

Thanks a ton.

1. Checked in your docs. Please take a look.
2. XSP should be working now.
3. Did you try using "context:///" (note the extra '/') instead of context://. If this does not
work, please let me know.

If all's well, please submit your sample.

Thanks,
dims

--- Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de> wrote:
> On 15.Jun.2001 -- 04:34 AM, Davanum Srinivas wrote:
> > Also, It will be *REALLY* helpful if you could submit a sample that shows off how to use the
> > LogicSheet and actions. Finally Please consider submitting some documentation similar to the
> ones
> > in xdocs directory to make it easy for people to make use of your contribution. FYI, You can
> use
> > "build docs" to build the documentation.
> 
> Davanum,
> 
> the attached file is the reworked documentation from the patch
> accompanying mail. I have not provided entries for docs-book.xml or
> site-book.xml since I was unsure about where to put it.
> 
> Would be quite nice if there would be some guide line for
> docs eg. what documents qualify as "overview" and what as
> "technical". 
> 
> An example is not included because
> a) xsp seems to be broken right now (CVS monday)
> b) I'm still not able to use context:// in a sub-sitemap. The file is
>    always searched for in $COCOON_DIR
> 
> 	Chris.
> 
> -- 
> C h r i s t i a n       H a u l
> haul@informatik.tu-darmstadt.de
>     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
> > <?xml version="1.0"?>
> <!DOCTYPE document SYSTEM "dtd/document-v10.dtd">
> <document> 
>   <header> 
> 	 <title>Using Form Validation</title>
> 	 <version>0.1</version> 
> 	 <type>Overview document</type> 
> 	 <authors>
>            <person name="Christian Haul" email="haul@informatik.tu-darmstadt.de"/> 
> 	 </authors> 
>   </header> 
>   <body> 
>    <s1 title="Introduction?"> 
>    <p>
>    For most web applicatipns input is essential. Cocoon provides a
>    variety of modules to support basic interaction like simple syntax
>    checking of input data or writing input data to databases.
>    </p>
>    <p>
>    This is about sntax checking. See
>    org.apache.cocoon.acting.DatabaseAbstractAction (in javadocs) for
>    details on database interaction.
>    </p>
>     <p>
>     FormValidatorAction communicates to the application a verbose
>     error status through an request attribute. In addition a taglib
>     allows easy access to the results. On top of that this taglib
>     gives access to the attributes for parameters declared in those
>     sections in descriptor.xml relevant to the validation process.
>     </p>
>     <s2 title="The Descriptor File">
>     <p>
>     For details on the syntax of the descriptor file see
>     javadocs. Basically it constists of two sections, a list of
>     parameters and their properties and a list of constraints or
>     constraint sets. The file syntax is set up so that it can be
>     shared with the database actions.
>     </p>
>      <source>
> <![CDATA[
> <?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?$">
> 
>    <constraint-set name="car-reservation">
>        <validate name="persons"/>
>        <validate name="deposit" min="50.0"/>
>        <validate name="email"/>
>     </constraint-set>
> 
> </root>
> ]]>
>      </source>
>     <p>
>     The aboce could for example describe expected input from a reservation
>     form. Specifications in a constraint set take preceedence over
>     the general ones.
>     </p>
>     </s2>
>     <s2 title="Sitemap Usage">
>     <p>
>     To take advantage of the form validator action create two
>     pages. One for the input form and one indicating the acceptance of
>     the reservation. Create a pipeline in your sitemap so that the
>     confirmation page is only shown when the action completed
>     successfully and the input form is returned otherwise.
>     </p>
>      <source>
> <![CDATA[
> <?xml version="1.0"?>
>    <map:match pattern="car-reservation">
>      <map:act type="form-validator">
>         <!-- add you favourite database action here -->
>         <map:parameter name="descriptor" value="descriptor.xml"/>
>         <map:parameter name="validate-set" value="car-reservation"/>
> 	<map:generate type="serverpages" src="OK.xsp"/>
> 	<map:transform src="stylesheets/dynamic-page2html.xsl"/>
> 	<map:serialize/>
>      </map:act>
>      <map:generate type="serverpages" src="test/ERROR.xsp"/>
>      <map:transform src="stylesheets/dynamic-page2html.xsl"/>
>      <map:serialize/>
>    </map:match>
> ]]>
>      </source>
>      <p>
>      Note here that you may not use a redirection to point to the
>      pages if you would like to access the validation results e.g. on
>      the error page. A redirection would create a new request object
>      and thus discard the validation results.
>      </p>
>     </s2>
>     <s2 title="XSP Usage">
>     <p>
>     To give the user some feedback why her/his submitted data was rejected
>     there is a special taglib "xsp-formval". Declare its name space as
>     usual.
>     </p>
>     <p>
>     If only interested in validation results, just 
>     </p>
>      <source>
> <![CDATA[
>      <xsp:logic>
> 	 if (!<xsp-formval:is-ok name="persons"/>) {
> 	      <myapp:error>(ERROR)</myapp:error>
>          };
>      </xsp:logic>
> ]]>
>      </source>
>      <p>
>      Internationalization issues are a separate concern and are not
>      discussed here.
>      </p>
>      <p>
>      Currently the following validation result codes are supported:
>      </p>
> 	 <table>
> 	 <tr><th>tag</th><th>Meaning</th></tr>
> 	 <tr><td>xsp-formval:is-ok</td><td>no error occurred,
> 	                                   parameter successfully 
> 					   checked</td></tr>
> 	 <tr><td>xsp-formval:is-error</td><td>some error occurred, 
> 	                                      this is a result that 
> 					      is never set but serves 
> 					      as a comparison target
> 					   </td></tr>
> 	 <tr><td>xsp-formval:is-null</td><td>the parameter is null but 
> 	                                     isn't allowed to</td></tr>
> 	 <tr><td>xsp-formval:is-toosmall</td><td>either value or
> 	                                        length in case of a
> 						string is less than
> 						the specified
> 						minimum</td></tr>
> 	 <tr><td>xsp-formval:is-toolarge</td><td>either value or
> 	                                         length in case of a
> 						 string is greater
> 						 than the specified
> 						 maximum</td></tr>			 
> 	 <tr><td>xsp-formval:is-nomatch</td><td>a string parameter's
> 	                                        value is not matched
> 						by the specified
> 						regular expression</td></tr>
> 	 <tr><td>xsp-formval:is-notpresent</td><td>this is returned
> 	                                           when the result of
> 	                                           a validation is
> 						   requested but no
> 						   such result is
> 						   found in the
> 						   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.
>      </p>
>      <p>
>      First set the url of the file or resource that contains the
>      parameter descriptions and constraint sets.  This needs to be an
>      ancestor to all other tags (of this taglib). Multiple use of this
>      tag is allowed (although probably not necessary).
>      </p>       
>      <p>  
>      You need to do this only if you plan to query the
>      descriptor file or if you'd like to use the shorthand
>      below. 
>      </p>
>      <source>
> <![CDATA[
>   <xsp-formval:descriptor name="descriptor.xml" constraint-set="reservation">
>      deposit must be at least EUR <xsp-formval:get-attribute parameter="deposit" name="min"/>
>   </xsp-formval:descriptor>
> ]]>
>      </source>
>      <p>
>      If you need to use one parameter a lot, there's a short hand. Use
>      this e.g. if you'd like to set up the properties of an input tag
>      according to the information from the descriptor file or if you'd
>      like to give detailed error messages.
>      </p>
>      <p>
>      Note that you can specify additional attributes in the
>      description file that are not understood (and therefore ignored)
>      by the FormValidatorAction but that could be queried here. This
>      might be e.g. the size of the input field which might be
>      different from the max-len a parameter can take.
>      </p>
>      <source>
> <![CDATA[
>   <xsp-formval:descriptor name="descriptor.xml" constraint-set="car-reservation">
>      <xsp-formval:validate name="deposit">
>      <xsp:logic>
> 	 if (<xsp-formval:is-null/>) {
> 	      <myapp:error> (you must specify a deposit)) </myapp:error>
> 	 } else if ( <xsp-formval:is-toosmall/> ) {
> 	      <myapp:error> (deposit is too small (&lt; <xsp-formval:get-attribute
> name="min"/>))</myapp:error>
>          } else if ( <xsp-formval:is-toolarge/> ) {
> 
=== message truncated ===> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 15.Jun.2001 -- 04:34 AM, Davanum Srinivas wrote:
> Also, It will be *REALLY* helpful if you could submit a sample that shows off how to use the
> LogicSheet and actions. Finally Please consider submitting some documentation similar to the ones
> in xdocs directory to make it easy for people to make use of your contribution. FYI, You can use
> "build docs" to build the documentation.

Davanum,

the attached file is the reworked documentation from the patch
accompanying mail. I have not provided entries for docs-book.xml or
site-book.xml since I was unsure about where to put it.

Would be quite nice if there would be some guide line for
docs eg. what documents qualify as "overview" and what as
"technical". 

An example is not included because
a) xsp seems to be broken right now (CVS monday)
b) I'm still not able to use context:// in a sub-sitemap. The file is
   always searched for in $COCOON_DIR

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Re: [C2] actions, forms, etc.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 19.Jun.2001 -- 01:28 PM, Neeme Praks wrote:
> > > 	* form name
> 
> Well, maybe this can be solved through some other mechanisms, but currently
> I'm using it to identify the form where to show errors. Real-life case:
> * I have a page with many forms.
> * I submit one of the forms, some errors occur (they do not have to be
> validation errors, could be some unexpected exceptions also).
> * Because of an error, I do an internal redirect back to the old page with
> many forms.
> * While generating the old page, I need to know on which form I should show
> the error(s).

OK. But you need to know which form was submitted in the first
place. So this is probably already encoded in the value of the submit
parameter or in the URL of the form's action attribute.

I think this is nothing the validation action know about. It only
knows about the constraint set it checks against. 

So, do you think it would be a good idea to store the name of the
constraint set (and probably of the descriptor file) as well as an
request attribute?  Provided that the only access such a page is
guarded by the validation action it would probably do to read out the
additional data from the descriptor file for input lengths etc. But
hold on, it wouldn't help if there were several forms on a page :-|

How should the name of the form be incorparated?

> > > 	* field name
> >
> > Thus when an error occured and the action directs the flow to the
> > error page every parameter has to be checked to see what when
> > wrong. Hence you're not provided with the name of the offending field
> > but with a per field status.
> 
> well, then you already have the name of the field? :-)

Yes, indeed. I envisioned that error messages would appear close to
the input field itself. Like "input your name:____________ (please
do fill in this one!)". If you want to put a list with error messages
at the top of the form, this is probably not very convenient. Since
the results are stored in a Map you could iterate over it and see
which parameters violated the constraints.

> > > 	* related data (optional)
> 
> It is dynamic. For example, I have an web-based email application (e.g.
> Hotmail) that allows to enter more than one email address in the "to" field.
> After the user has entered something, I run it though the validator that
> checks if the list was well formed. If the list was not well formed or if
> one of the addresses was incorrect, then I need to point out, which address
> was incorrect. With this dynamic data, I could stuff this data in there. Ok?

So far FormValidatorActions does only simple syntax checks and does
not explain the error to the user. Frankly, I don't think the user is
that dumb that (s)he will not figure it out. Well, if the constraint
is a regular expression (s)he will probably not be able to do it. But
the RE library does not indicate at wich point an expression
failed. And I don't see how this could be achieved easily.

I'm afraid that for those cases you'll either have to code such a
logic on your XSP or write an application specific action.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: [C2] actions, forms, etc.

Posted by Neeme Praks <ne...@one.ee>.
> -----Original Message-----
> From: Christian Haul [mailto:haul@dvs1.informatik.tu-darmstadt.de]
> Sent: Friday, June 15, 2001 11:17 AM
>
> I think the patch addresses almost all of your points. There are only
> a small number of error codes available corresponding to the
> validation rules currently supported. They are organized in a
> java.util.HashMap with the parameter name as key.
>
> > 	* form name
>
> Mmmh, I reckon this would be encoded as a parameter but wouldn't be
> determined by the validation process, would it. Please give an example
> how you would like to see this supported.

Well, maybe this can be solved through some other mechanisms, but currently
I'm using it to identify the form where to show errors. Real-life case:
* I have a page with many forms.
* I submit one of the forms, some errors occur (they do not have to be
validation errors, could be some unexpected exceptions also).
* Because of an error, I do an internal redirect back to the old page with
many forms.
* While generating the old page, I need to know on which form I should show
the error(s).

> > 	* field name
>
> Thus when an error occured and the action directs the flow to the
> error page every parameter has to be checked to see what when
> wrong. Hence you're not provided with the name of the offending field
> but with a per field status.

well, then you already have the name of the field? :-)

> > 	* related data (optional)
>
> Related data -- I don't know what this could be. If this is static and
> related to a field it could be retrieved from the descriptor.xml file
> through xsp-formval:get-attribute. If it's dynamically related to the
> validation process -- I don't know. If you could provide an example I
> will try to see how it fits or what could be done to cater for it.

It is dynamic. For example, I have an web-based email application (e.g.
Hotmail) that allows to enter more than one email address in the "to" field.
After the user has entered something, I run it though the validator that
checks if the list was well formed. If the list was not well formed or if
one of the addresses was incorrect, then I need to point out, which address
was incorrect. With this dynamic data, I could stuff this data in there. Ok?

Neeme


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by Martin Man <Ma...@seznam.cz>.
hi all,
	thanx dims for applying the patch, as I said to Christian already I'm
at the moment quite busy with finishing my graduate studies, and can't follow
this hide traffic, this will anyway change 25 of June, if I'll survive this
day :-)) and than I'll go back working...


than again,
martin

On Fri, Jun 15, 2001 at 04:34:27AM -0700, Davanum Srinivas wrote:
> Christian,
> 
> > 
> > PS: as of Friday 0900 UTC the discussed patch seems no to have made it
> > into CVS.
> > 
> 
> Thanks for your contribution. Checked it in. Please take a look to see if all's well. (I have
> checked in the EnumerationFactory as is into org/apache/cocoon/util as i don't like mini-jars with
> just one file).
> 
> Also, It will be *REALLY* helpful if you could submit a sample that shows off how to use the
> LogicSheet and actions. Finally Please consider submitting some documentation similar to the ones
> in xdocs directory to make it easy for people to make use of your contribution. FYI, You can use
> "build docs" to build the documentation.
> 
> Thanks,
> dims
> 
> =====
> Davanum Srinivas, JNI-FAQ Manager
> http://www.jGuru.com/faq/JNI
> 
> __________________________________________________
> Do You Yahoo!?
> Spot the hottest trends in music, movies, and more.
> http://buzz.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 

-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by Davanum Srinivas <di...@yahoo.com>.
Christian,

> 
> PS: as of Friday 0900 UTC the discussed patch seems no to have made it
> into CVS.
> 

Thanks for your contribution. Checked it in. Please take a look to see if all's well. (I have
checked in the EnumerationFactory as is into org/apache/cocoon/util as i don't like mini-jars with
just one file).

Also, It will be *REALLY* helpful if you could submit a sample that shows off how to use the
LogicSheet and actions. Finally Please consider submitting some documentation similar to the ones
in xdocs directory to make it easy for people to make use of your contribution. FYI, You can use
"build docs" to build the documentation.

Thanks,
dims

=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 14.Jun.2001 -- 07:15 PM, Neeme Praks wrote:
> * validation data: With my current form validation system (from Turbine),
> I'm able to specify the following information about the error on a form:
> 	* error code/name

I think the patch addresses almost all of your points. There are only
a small number of error codes available corresponding to the
validation rules currently supported. They are organized in a
java.util.HashMap with the parameter name as key. 

> 	* form name

Mmmh, I reckon this would be encoded as a parameter but wouldn't be
determined by the validation process, would it. Please give an example
how you would like to see this supported.

> 	* field name

Thus when an error occured and the action directs the flow to the
error page every parameter has to be checked to see what when
wrong. Hence you're not provided with the name of the offending field
but with a per field status.

> 	* related data (optional)

Related data -- I don't know what this could be. If this is static and
related to a field it could be retrieved from the descriptor.xml file
through xsp-formval:get-attribute. If it's dynamically related to the
validation process -- I don't know. If you could provide an example I
will try to see how it fits or what could be done to cater for it.


On 14.Jun.2001 -- 08:49 PM, Piroumian, Konstantin wrote:
> > Instead, I would like to be able to pass the parameters to some i18n
> package
> > like XMLResourceBundle in Avalon, or i18n transformer in C2 (I haven't
> > looked deeper into i18n transformer yet, so I know very little about
> > parameter substitution support there).
> 
> About i18n transformer: param substitution is supported. And the above task,
> I think, can be easily performed in locale-sensitive manner if you change it
> like this:

Konstantin, thank you for pointing it out. I too believe that
internationalization is a different concern and should therefore be
separated from the validation process.

	Chris.

PS: as of Friday 0900 UTC the discussed patch seems no to have made it
into CVS.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [C2] actions, forms, etc.

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Hi!

> [... long email cut ...]
>
> Good start. However, here are some issues to consider:
> * i18n: The last thing I would like to do in my webapp is to "hardcode"
the
> error messages like below
> -----------------
>   <xsp-formval:descriptor name="descriptor.xml"
> constraint-set="user-input">
>      this parameter must be at least <xsp-formval:get-attribute
> parameter="input" name="min"/>
>   </xsp-formval:descriptor>
> -----------------
> Instead, I would like to be able to pass the parameters to some i18n
package
> like XMLResourceBundle in Avalon, or i18n transformer in C2 (I haven't
> looked deeper into i18n transformer yet, so I know very little about
> parameter substitution support there).

About i18n transformer: param substitution is supported. And the above task,
I think, can be easily performed in locale-sensitive manner if you change it
like this:

<xsp-formval:descriptor name="descriptor.xml"
 constraint-set="user-input">
     <i18n:translate>
        <i18n:text>this parameter must be at least {0}</i18n:text>
        <i18n:param><xsp-formval:get-attribute
 parameter="input" name="min"/></i18n:param>
     </i18n:translate>
 </xsp-formval:descriptor>

>...
> Comments?
>
> Neeme

Regards,
    Konstantin Piroumian.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: [C2] actions, forms, etc.

Posted by Neeme Praks <ne...@one.ee>.
> -----Original Message-----
> From: Christian Haul [mailto:haul@dvs1.informatik.tu-darmstadt.de]
> Sent: Tuesday, June 12, 2001 7:32 PM
> Subject: Re: [C2] actions, forms, etc.

[... long email cut ...]

Good start. However, here are some issues to consider:
* i18n: The last thing I would like to do in my webapp is to "hardcode" the
error messages like below
	-----------------
	  <xsp-formval:descriptor name="descriptor.xml"
constraint-set="user-input">
	     this parameter must be at least <xsp-formval:get-attribute
parameter="input" name="min"/>
	  </xsp-formval:descriptor>
	-----------------
Instead, I would like to be able to pass the parameters to some i18n package
like XMLResourceBundle in Avalon, or i18n transformer in C2 (I haven't
looked deeper into i18n transformer yet, so I know very little about
parameter substitution support there).

* validation data: With my current form validation system (from Turbine),
I'm able to specify the following information about the error on a form:
	* error code/name
	* form name
	* field name
	* related data (optional)
Your solution covers only some parts of this and adds some new capabilities
like <xsp-formval:get-attribute>. I would like to see the full support also
for the information above.

Comments?

Neeme


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org