cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@cup.hp.com>
Subject Re: [Flow] Going back and forth with continuations
Date Mon, 16 Dec 2002 20:07:45 GMT

On Monday, Dec 16, 2002, at 08:55 US/Pacific, Christopher Oliver wrote:

> Ovidiu Predescu wrote:
>
>>
>> On Sunday, Dec 15, 2002, at 23:59 US/Pacific, Ugo Cei wrote:
>>
>>> Ovidiu Predescu wrote:
>>>
>>>> One solution would be to define a pseudo-continuation, just after 
>>>> you finish the function initialization code, which could be 
>>>> referred from the View page template. Something like:
>>>> function myFunc()
>>>> {
>>>>   var a;
>>>>   // Long initialization code here
>>>>   startForm(); // Creates a dummy continuation, with no page
>>>>                // being sent to the browser
>>>
>>>
>>> Since you didn't provide the code for this startForm() function, I 
>>> tried to write it myself, copying the code from _sendPageAndWait() 
>>> minus the call to cocoon.forwardTo():
>>>
>>> function startForm(timeToLive)
>>> {
>>>   var k = new Continuation();
>>>   var kont = new WebContinuation(cocoon, k, lastContinuation, 
>>> timeToLive);
>>>   suicide();
>>> }
>>>
>>> Do you think this would work?
>>
>>
>> Great Ugo! This should work fine, but please do let me know if you 
>> encounter any issues.
>>
> I may be wrong, but I think this needs to be:
>
> function startForm(timeToLive) {
>     var k = new Continuation();
>     var wk = new WebContinuation(cocoon, k, lastContinuation, 
> timeToLive);
>     lastContinuation = k;
>     return k;
> }
>
> Calling suicide() would terminate the script and since no page was 
> sent there is no client involved to restart it.

Thanks for catching this one, Chris! I should not post anything so 
early in the morning, not before I get the coffee at least ;)

One small problem with the function you defined, it returns the 
JavaScript continuation, instead of the WebContinuation object. With 
this fix, the code should read like this:

function startForm(timeToLive) {
     var k = new Continuation();
     var wk = new WebContinuation(cocoon, k, lastContinuation, 
timeToLive);
     lastContinuation = wk;
     return wk;
}

Regards,
Ovidiu


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


Mime
View raw message