cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <res1c...@verizon.net>
Subject Re: v2 Form.js how does onValidate work?
Date Wed, 17 Mar 2004 19:18:35 GMT
Tim Larson wrote:

>On Tue, Mar 16, 2004 at 09:16:38PM +0000, Tim Larson wrote:
>  
>
>>I am trying to migrate to the v2 Form.js, but I am having trouble
>>understanding how the onValidate handling works.  From reading to code
>>it looks to me like it would not work correctly, but the sample form
>>work properly.  Could somebody explain how the interaction of the
>>regular validation, the onValidate function, and the continuation
>>bookmark works? (via email or IRC)
>>    
>>
> 
>One of the specific questions is in this code:
>    var userErrors = 0;
>    this.formWidget_.validationErrorListener = function(widget, error) {
>        if (error != null) {
>            userErrors++;
>        }
>    }
>    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;
>
>How does the call to "this.onValidate(this);" affect whether the form is
>redisplayed to the user when it does not modify either of the variables
>"finished" or "userErrors"?
>  
>
See ScriptableWidget.notifyValidationErrorListener(). In the body of the 
(user-defined) onValidate() function, any call to 
<Widget>.setValidationError()  implicitly invokes the 
validationErrorListener function which, in turn,  increments "userErrors".

>Another question is what line triggers the return to the bookmarked
>continuation?  My first guess would be the line "cocoon.continuation = ...",
>but that would mean the next line would never get executed...any help
>understanding this would be appreciated.
>  
>
The continuation is  invoked by this line:

   this.local_.webContinuation.continuation(this.local_.webContinuation);

Since the continuation is created in Form.setBookmark(), this call 
causes the script to discard its current context and resume immediately 
following the call to setBookmark().  The script then continues into 
Form.showForm() and redisplays the page.

The assignment to cocoon.continuation is needed to set up the correct 
parent for the continuation to be created by cocoon.sendPageAndWait() in 
showForm().

HTH,

Chris

Mime
View raw message