cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roel Croonenberghs <Roel.Croonenber...@sofico.be>
Subject Re: validation
Date Fri, 22 Dec 2006 07:27:21 GMT
it works.

thank you very much

Roel Croonenberghs





Jason Johnston <cocoon@lojjic.net> 
21/12/2006 01:49
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: validation






I looked back at the 2.1.4 Woody source code and the validation-errors 
styling element was indeed available at that time.  Of course, I forgot 
that since you're using Woody and not CForms, the namespace is 
different, so it would probably be wi:validation-errors rather than 
fi:validation-errors.

If that still doesn't work, then you probably don't have the proper 
template in your woody-field-styling.xsl.  Here's the template that 
needs to exist in the stylesheet:

--------------------

   <xsl:template match="wi:validation-errors">
     <xsl:variable name="header">
       <xsl:choose>
         <xsl:when test="header">
           <xsl:copy-of select="header"/>
         </xsl:when>
         <xsl:otherwise>
           <p class="woody-validation-errors">The following errors have 
been detected (marked with !):</p>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:variable name="footer">
       <xsl:choose>
         <xsl:when test="footer">
           <xsl:copy-of select="footer"/>
         </xsl:when>
         <xsl:otherwise>
           <p class="woody-validation-errors">Please, correct them and 
re-submit the form.</p>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:variable name="frm" select="ancestor::wi:form-template"/>
     <xsl:if test="$frm and $frm//wi:validation-message">
       <xsl:copy-of select="$header"/>
       <ul>
         <xsl:for-each select="$frm//wi:validation-message">
           <li class="woody-validation-error">
             <xsl:if test="../wi:label">
               <xsl:value-of select="../wi:label"/><xsl:text>: </xsl:text>
             </xsl:if>
             <xsl:value-of select="."/>
           </li>
         </xsl:for-each>
       </ul>
       <xsl:copy-of select="$footer"/>
     </xsl:if>
   </xsl:template>

---------------------

You can of course customize it to suit your needs.  Then just add the 
<wi:validation-errors /> in your display template and it should work. 
Let us know if you still have trouble.

--Jason



Roel Croonenberghs wrote:
> 
> 
> It does not work   *snif
> 
> 
> *Jason Johnston <cocoon@lojjic.net>*
> 
> 20/12/2006 15:28
> Please respond to
> users@cocoon.apache.org
> 
> 
> 
> To
>                users@cocoon.apache.org
> cc
> 
> Subject
>                Re: validation
> 
> 
> 
> 
> 
> 
> 
> 
> Roel Croonenberghs wrote:
>  >
>  > Hi,
>  >
>  > Where do I put that javascript code? I still use cocoon 2.1.4.  width
>  > woody forms.
>  > Is there no other way?
> 
> 
> I don't know if it was available in the version of woody you're using,
> but in current CForms there is the <fi:validation-errors /> element
> which aggregates all the validation errors in a single place on the
> page.  See the bottom of
> http://cocoon.apache.org/2.1/userdocs/publishing/xslt.html for details.
> 
> 
> 
>  > *"Robby Pelssers, AGP" <robby.pelssers@agp.nl>*
>  >
>  > 20/12/2006 12:11
>  > Please respond to
>  > users@cocoon.apache.org
>  >
>  >
>  > 
>  > To
>  >                  <users@cocoon.apache.org>
>  > cc
>  > 
>  > Subject
>  >                  RE: validation
>  >
>  >
>  > 
>  >
>  >
>  >
>  >
>  >
>  > Hi Roel,
>  > 
>  > you could in javascript ask your form to validate itself....
>  > 
>  > suppose we have something like
>  > 
>  >
>  > *var* form = *new* Form("userform.xml");
>  >
>  > var formWidget = form.form;
>  >
>  > suppose now your formWidget has a field with id="validationError"
>  > 
>  > then you could write in your while(true) loop something like
>  > 
>  >
>  > *if* ("save-data".equals(form.submitId)) {
>  >
>  >     if (!formWidget.isValid()) {
>  >
>  >         formWidget.lookupWidget("validationError").setValue("There 
was a
>  > problem validating your form");
>  >
>  >     }
>  >
>  > }
>  >
>  > Cheers,
>  > Robby Pelssers
>  > 
>  >
>  > 
------------------------------------------------------------------------
>  > *Van:* Roel Croonenberghs [mailto:Roel.Croonenberghs@sofico.be] *
>  > Verzonden:* woensdag 20 december 2006 11:43*
>  > Aan:* users@cocoon.apache.org*
>  > Onderwerp:* Re: validation
>  >
>  >
>  > Hello,
>  >
>  > I use the required attribute. And I get a  !  next to the filed. When 
I
>  > click that   !   then I get to see te message. But I want to (next to
>  > this behaviour ) that i can display a message at the bottom of my 
form
>  > to tell the user that the form did not validate. (because users tend 
to
>  > oversee these   !      even when they are in red)
>  >
>  > so is it possible to check that at least 1 (one) field is not 
validated
>  > (it doesn't matter witch) and then show a message?
>  >
>  >
>  > pe;
>  >
>  >
>  > situation now after submit;
>  >
>  > field1   myname        *
>  > field2   myadres *
>  > field3                * ! 
>  > field4   mytelephone *
>  >
>  > * required
>  >
>  >
>  >
>  > situation wanted after submit
>  >
>  >
>  > field1   myname        *
>  > field2   myadres *
>  > field3                * ! 
>  > field4   mytelephone *
>  >
>  > * required
>  >
>  > There was a problem validating your form
>  >
>  >
>  >
>  >
>  > Tnx
>  >
>  >
>  >
>  >
>  >
>  > *"bart remmerie" <remmerie@gmail.com>*
>  >
>  > 20/12/2006 11:33
>  > Please respond to
>  > users@cocoon.apache.org
>  >
>  > 
>  > To
>  >                  users@cocoon.apache.org
>  > cc
>  > 
>  > Subject
>  >                  Re: validation
>  >
>  >
>  >
>  > 
>  >
>  >
>  >
>  >
>  >
>  >
>  > Dear Roel,
>  >
>  > In your form-definition, you can declare whether or not a field is 
> required:
>  > <fd:field id="..." required="true|false" state="...">
>  > (See http://cocoon.apache.org/2.1/userdocs/widgets/widget_field.html)
>  >
>  > When a field has required="true", a message is displayed when the
>  > field is not filled out (on form-submit) (when using standard
>  > validation).
>  >
>  > Next to that, fields that have the required="true" attribute, are
>  > marked and a ! appears displaying the validation error (after
>  > attempted submission)
>  >
>  > Bart
>  >
>  >
>  > 2006/12/19, Roel Croonenberghs <Roel.Croonenberghs@sofico.be>:
>  >  >
>  >  > Hello,
>  >  >
>  >  > I'm using cocoon widgets. I have a form with different widgets. 
> Some are
>  >  > required, not all. How can I show one message if one of the 
required
>  > widgets
>  >  > is not filled in?
>  >  >
>  >  > tnx
>  >  >
>  >  > Roel
>  >
>  >
>  > --
>  > Bart Remmerie
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>  > For additional commands, e-mail: users-help@cocoon.apache.org
>  >
>  >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


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



Mime
View raw message