You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <u....@cbim.it> on 2003/03/28 12:01:20 UTC
Understanding continuations
I'm having some problems with an application that uses the Flow and
XMLForms. I'm getting an invalid continuation error and after 4 hours of
debugging I still cannot understand why. Tracing the execution of the
flow, I've come to this snippet in xmlForm.js that I don't understand fully:
if (wk != null) {
var jswk = wk.userObject;
jswk.continuation(jswk);
// note: not reached
}
What kind of object is jswk? Is it an
o.a.c.components.flow.javascript.JSWebContinuation? Where is this
"continuation" method defined (assuming it is a method) and why is it
passed an instance of itself?
Thanks in Advance,
Ugo
--
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it
Re: Understanding continuations
Posted by Ugo Cei <u....@cbim.it>.
Christopher Oliver wrote:
> Try setting a breakpoint on xmlForm.js, line 178:
I did but it never stops there. There's a couple more interesting facts,
though:
1. If I change the "xmlform-scope" parameter's value from "request" to
"session", the problem I described does not manifest itself ...
2. ... BUT if two people use the application at the same time, one of
the two is bound to get errors like "callFunction is not a function" or
messages about null objects.
Thus, I suspect there is some problem with session handling in
xmlForm.js, but since the code is quite complex and I've spent the
latest 10 hours doing trial&error debugging (besides catering for some
servers that went down due to a missing UPS :-( ) , I'm not going to
tackle it this evening. Maybe monday.
Ugo
--
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it
Re: Understanding continuations
Posted by Christopher Oliver <re...@verizon.net>.
Try setting a breakpoint on xmlForm.js, line 178:
174 this._sendView(uri, k);
175 // _sendView creates a continuation, the invocation of which
176 // will return right here: it is used to implement
177 // <xf:submit continuation="forward">
178 if (this.dead || cocoon.request == null) {
179 // this continuation has been invalidated
180 handleInvalidContinuation();
181 suicide();
182 }
That is where you will jump to when jswk.continuation(jswk) is called.
Hope this helps,
Chris
Ugo Cei wrote:
> Christopher Oliver wrote:
>
>> What do you mean by "invalid continuation error"?
>
>
> I mean that the handleInvalidContinuation function in system.js is
> called and it redirects to my handler page ... BUT ... the "id"
> parameter is empty!
>
> What I'm doing is this: I have an XMLForm with a submit button that is
> like the following:
>
> <xf:submit id="next" continuation="forward">
> <xf:caption>OK</xf:caption>
> </xf:submit>
>
> After the XMLForm transformation, this is sent to the browser as:
>
> <input value="OK" type="submit"
> name="cocoon-action-0d3e48210a8f347652091a6d463f6470716d154b"
> continuation="forward">
>
> I've added a few debug statements in xmlForm.js to see what's going on:
>
> var command = getCommand();
> log.debug("xmlForm: command = " + command); //DEBUG
> if (command != undefined) {
> // invoke a continuation
> var continuationsMgr =
>
> cocoon.componentManager.lookup(Packages.org.apache.cocoon.components.flow.ContinuationsManager.ROLE);
>
> var wk = continuationsMgr.lookupWebContinuation(command);
> wk.display(); // DEBUG
> cocoon.componentManager.release(continuationsMgr);
> if (wk != null) {
> var jswk = wk.userObject;
> jswk.display(); // DEBUG
> jswk.continuation(jswk);
> // note: not reached
> }
> handleInvalidContinuation(command);
> return;
> }
>
> And these are the contents of flow.log:
>
> DEBUG (2003-03-28) 12:34.24:737 [flow] (/cefalee/arruolamento)
> Thread-9/JSLog: xmlForm: command = 0d3e48210a8f347652091a6d463f6470716d154b
> DEBUG (2003-03-28) 12:34.24:739 [flow] (/cefalee/arruolamento)
> Thread-9/WebContinuation:
> WK: Tree
> WK: WebContinuation 0d3e48210a8f347652091a6d463f6470716d154b ExpireTime
> [1048854377943]
> DEBUG (2003-03-28) 12:34.24:741 [flow] (/cefalee/arruolamento)
> Thread-9/WebContinuation:
> WK: Tree
> WK: WebContinuation 0d3e48210a8f347652091a6d463f6470716d154b ExpireTime
> [1048854377943]
>
> So it looks like the command is correct and both wk and jswk are valid
> continuations, but the handleInvalidContinuation handler is always
> called and with a null id! I'd like to debug this, but the debugger is
> not able to step into the "jswk.contiunation(jswk)" call.
>
> What is stranger is that I have another application that is using the
> same Cocoon version (straight out of CVS this morning) and the same
> techniques for form handling and this one works! I've been staring at
> the code for 4 hours and still cannot see what is different between the
> two. :-(
>
> Ugo
>
Re: Understanding continuations
Posted by Ugo Cei <u....@cbim.it>.
Christopher Oliver wrote:
> What do you mean by "invalid continuation error"?
I mean that the handleInvalidContinuation function in system.js is
called and it redirects to my handler page ... BUT ... the "id"
parameter is empty!
What I'm doing is this: I have an XMLForm with a submit button that is
like the following:
<xf:submit id="next" continuation="forward">
<xf:caption>OK</xf:caption>
</xf:submit>
After the XMLForm transformation, this is sent to the browser as:
<input value="OK" type="submit"
name="cocoon-action-0d3e48210a8f347652091a6d463f6470716d154b"
continuation="forward">
I've added a few debug statements in xmlForm.js to see what's going on:
var command = getCommand();
log.debug("xmlForm: command = " + command); //DEBUG
if (command != undefined) {
// invoke a continuation
var continuationsMgr =
cocoon.componentManager.lookup(Packages.org.apache.cocoon.components.flow.ContinuationsManager.ROLE);
var wk = continuationsMgr.lookupWebContinuation(command);
wk.display(); // DEBUG
cocoon.componentManager.release(continuationsMgr);
if (wk != null) {
var jswk = wk.userObject;
jswk.display(); // DEBUG
jswk.continuation(jswk);
// note: not reached
}
handleInvalidContinuation(command);
return;
}
And these are the contents of flow.log:
DEBUG (2003-03-28) 12:34.24:737 [flow] (/cefalee/arruolamento)
Thread-9/JSLog: xmlForm: command = 0d3e48210a8f347652091a6d463f6470716d154b
DEBUG (2003-03-28) 12:34.24:739 [flow] (/cefalee/arruolamento)
Thread-9/WebContinuation:
WK: Tree
WK: WebContinuation 0d3e48210a8f347652091a6d463f6470716d154b ExpireTime
[1048854377943]
DEBUG (2003-03-28) 12:34.24:741 [flow] (/cefalee/arruolamento)
Thread-9/WebContinuation:
WK: Tree
WK: WebContinuation 0d3e48210a8f347652091a6d463f6470716d154b ExpireTime
[1048854377943]
So it looks like the command is correct and both wk and jswk are valid
continuations, but the handleInvalidContinuation handler is always
called and with a null id! I'd like to debug this, but the debugger is
not able to step into the "jswk.contiunation(jswk)" call.
What is stranger is that I have another application that is using the
same Cocoon version (straight out of CVS this morning) and the same
techniques for form handling and this one works! I've been staring at
the code for 4 hours and still cannot see what is different between the
two. :-(
Ugo
--
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it
Re: Understanding continuations
Posted by Christopher Oliver <re...@verizon.net>.
Ugo Cei wrote:
> I'm having some problems with an application that uses the Flow and
> XMLForms. I'm getting an invalid continuation error and after 4 hours of
> debugging I still cannot understand why. Tracing the execution of the
> flow, I've come to this snippet in xmlForm.js that I don't understand
> fully:
>
> if (wk != null) {
> var jswk = wk.userObject;
> jswk.continuation(jswk);
> // note: not reached
> }
>
> What kind of object is jswk? Is it an
> o.a.c.components.flow.javascript.JSWebContinuation? Where is this
> "continuation" method defined (assuming it is a method) and why is it
> passed an instance of itself?
>
Yes, it is. The continuation property of JSWebContinuation returns a
JavaScript Continuation object, which is also a function that can be
called. When you do that the current function invocation (and call
stack) is discarded and replaced with the function invocation (and call
stack) stored within the continuation. That's why the next line is "not
reached".
I know it seems strange, but the continuation is passed "jswk" so that
it will become the return value of function it was captured in.
What do you mean by "invalid continuation error"?
Regards,
Chris