You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andrew MacDonald <an...@yahoo.com> on 2005/04/08 00:15:23 UTC

[CForms] how to remove a validation error?

Hello,
I'm performing form-level validation and have set an
error if the value of an upload widget
(customStylesheet) is null.  However, the upload
widget should only be validated depending on the value
of another widget (defaultStylesheet).

Here's my validation code:
<fd:validation>
<fd:javascript>
  var success = true;
  var defStyle =
widget.lookupWidget("defaultStylesheet");
  if (defStyle.value == 'custom') {
    var cusStyle =
widget.lookupWidget("customStylesheet");
    if (cusStyle.value == null) {
      cusStyle.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError("You
must provide a Custom Stylesheet if the Default
Stylesheet is set to Custom.", false));
      success = false;
    }
  }
  return success;
</fd:javascript>
</fd:validation>

The problem is that if the user sets the
defaultStylesheet to custom, tries to submit the form,
and then changes defaultStylesheet to something else,
the customStylesheet widget still has that validation
error.  How can I remove it?

I was looking at the removeValidator method for the
AbstractWidget class, but couldn't figure out how to
make it work.

Thanks,
Andrew


		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest

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


Re: [CForms] how to remove a validation error?

Posted by Adam Walsh <aw...@contal.net.au>.
Hi Andrew,

Looks like you just need to have cusStyle.setValidationError(null) 
somewhere in your validation javascript to clear out the error. Maybe 
something like:

<fd:validation>
<fd:javascript>
  var success = true;
  var defStyle = widget.lookupWidget("defaultStylesheet");
  var cusStyle = widget.lookupWidget("customStylesheet");
  cusStyle.setValidationError(null);
  if (defStyle.value == 'custom') {
    if (cusStyle.value == null) {
      cusStyle.setValidationError(new 
Packages.org.apache.cocoon.forms.validation.ValidationError("You must 
provide a Custom Stylesheet if the Default Stylesheet is set to 
Custom.", false));
      success = false;
    }
  }
  return success;
</fd:javascript>
</fd:validation>


Andrew MacDonald wrote:

>Hello,
>I'm performing form-level validation and have set an
>error if the value of an upload widget
>(customStylesheet) is null.  However, the upload
>widget should only be validated depending on the value
>of another widget (defaultStylesheet).
>
>Here's my validation code:
><fd:validation>
><fd:javascript>
>  var success = true;
>  var defStyle =
>widget.lookupWidget("defaultStylesheet");
>  if (defStyle.value == 'custom') {
>    var cusStyle =
>widget.lookupWidget("customStylesheet");
>    if (cusStyle.value == null) {
>      cusStyle.setValidationError(new
>Packages.org.apache.cocoon.forms.validation.ValidationError("You
>must provide a Custom Stylesheet if the Default
>Stylesheet is set to Custom.", false));
>      success = false;
>    }
>  }
>  return success;
></fd:javascript>
></fd:validation>
>
>The problem is that if the user sets the
>defaultStylesheet to custom, tries to submit the form,
>and then changes defaultStylesheet to something else,
>the customStylesheet widget still has that validation
>error.  How can I remove it?
>
>I was looking at the removeValidator method for the
>AbstractWidget class, but couldn't figure out how to
>make it work.
>
>Thanks,
>Andrew
>
>
>		
>__________________________________ 
>Yahoo! Messenger 
>Show us what our next emoticon should look like. Join the fun. 
>http://www.advision.webevents.yahoo.com/emoticontest
>
>---------------------------------------------------------------------
>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