You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mark Lundquist <ml...@wrinkledog.com> on 2004/04/14 21:04:43 UTC
Re: [cforms] Clear validation error on a widget?
On Apr 14, 2004, at 11:50 AM, Mark Lundquist wrote:
> On Apr 14, 2004, at 10:37 AM, Mark Lundquist wrote:
>> On Apr 14, 2004, at 10:02 AM, Joerg Heinicke wrote:
>>> On 14.04.2004 18:36, Mark Lundquist wrote:
>>>> Hi,
>>>> I have a repeater whose rows contain:
>>>> • a text field that notionally is required, but is not declared
>>>> as such in the definition (see below)
>>>> • a "delete me" booleanfield.
>>>> The field is not @required="true", because if the user clicks to
>>>> add a row and then decides they don't want it after all, they must
>>>> check the "delete me" box on that row and submit the form. So this
>>>> state (text field empty, box checked) must be valid.
>>>> So I'm doing a check in the form.onValidate handler. I call
>>>> setValidationError() on the text widget in the error case (field
>>>> empty, "delete me" not checked), and that works fine.
>>>> But I also need the ability to clear the validation error if the
>>>> field is empty and the "delete me" box is checked. How do I do
>>>> this?
>>>> I tried setValidationError (null), but that didn't do the trick.
>>>> Any ideas?
>>>
>>> I might be wrong, but I'm nearly sure I have both working: required
>>> fields in a repeater, with delete me checkboxes and
>>> setValidationError(null). I'm using still 2.1.4 Woody, so part I
>>> might be caused by actions causing validation, but Sylvain has fixed
>>> this yesterday, so this should work too.
>>
>> One of the bad behaviors I'm seeing right now is that after I call
>> setValidationError (null) in the flowscript, I get output something
>> like this from <fi:valdatation-errors>:
>>
>> Your form had the following errors:
>> • null
>> Please fix and resubmit
>
> I debugged a bit, and it turns out that
> ScriptableWidget.jsFunction_setValidationError() is getting called
> with a value of (String) "null" for its 'message' parameter. It looks
> like the conversion of null to "null" is happening in
> org.mozilla.javascript.ScriptRuntime.call(), but I don't have that
> source (do I?) so I can't tell exactly what is going on. Anyway, if
> that is the case then I am probably hosed, right?
I just added ScriptableWidget.jsFunction_clearValidationError(), and
that seems to fix my trouble. When I get the chance, I'll submit a
patch, unless I hear otherwise...
~mark
Re: [cforms] Clear validation error on a widget?
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Apr 14, 2004, at 12:04 PM, Mark Lundquist wrote:
> I just added ScriptableWidget.jsFunction_clearValidationError(), and
> that seems to fix my trouble. <snip...>
Well, it _almost_ fixed it :-(.
But I was naïve about what I could expect from onValidate(). I clear
the validation error, but I'm clearing it after the fact — the form has
already decided that it needs to be redisplayed because of that
validation error:
From v2/Form.js:
var finished = javaWidget.process(formContext);
if (this.onValidate) {
this.onValidate(this);
}
if (!finished || userErrors > 0) {
cocoon.continuation = this.local_.webContinuation;
this.local_.webContinuation.continuation(this.local_.webContinuation);
}
return wk;
So there's nothing I can do in onValidate() that can prevent this loop
from continuing, so the result is that I have to submit twice.
Rats!
~ mark