Creating and halting flow continuations

2004-09-08 Thread Ulf Sahlin
Hello!

I need to:

1. create a continuation
2. put the id of the continuation in a deliveryUrl
3. redirect to a redirectUrl
4. suspend flowscript execution, until the remote system hosting redirectUrl
redirects the user to my deliveryUrl
5. resume from here (by sitemap-catching the deliveryUrl continuation id,
continuing the flowscript execution)


Is this possible? I tried to read
http://cocoon.apache.org/2.1/userdocs/flow/api.html on how creating
WebContinuations manually affect execution, but it doesn't say how and if I
could halt execution.


Best regards,
  Ulf Sahlin


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating and halting flow continuations

2004-09-08 Thread Emond Papegaaij
On Thursday 09 September 2004 00:08, Ulf Sahlin wrote:
> I need to:
>
> 1. create a continuation
> 2. put the id of the continuation in a deliveryUrl
> 3. redirect to a redirectUrl
> 4. suspend flowscript execution, until the remote system hosting
> redirectUrl redirects the user to my deliveryUrl
> 5. resume from here (by sitemap-catching the deliveryUrl continuation id,
> continuing the flowscript execution)
>
>
> Is this possible? I tried to read
> http://cocoon.apache.org/2.1/userdocs/flow/api.html on how creating
> WebContinuations manually affect execution, but it doesn't say how and if I
> could halt execution.

What you need is a 'redirectAndWait'. This is something that IMHO is missing 
in the current flow API, but very easy to implement. I don't have the cocoon 
source here at the moment, but take a look at the 'sendPageAndWait' method in 
the flow implementation you are using (probably javascript). This method 
should call 'sendPage' and some other stuff. The 'redirectAndWait' method you 
need will contain a 'redirect' (or is it 'redirectTo'?) and this other stuff. 
That's all you need.

A custom flow engine I'm working on as an example:
   public void sendPageAndWait(String uri, Object bizdata) {
 sendPage(uri, bizdata);
 getCont().endExecution(null);
   }

   public void redirectAndWait(String uri) {
 redirectTo(uri);
 getCont().endExecution(null);
   }

Good luck,
Emond

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating and halting flow continuations

2004-09-09 Thread Ulf Sahlin

Hello Emond! Thank your for your swift reply.

> > I need to:
> >
> > 1. create a continuation
> > 2. put the id of the continuation in a deliveryUrl
> > 3. redirect to a redirectUrl
> > 4. suspend flowscript execution, until the remote system hosting
> > redirectUrl redirects the user to my deliveryUrl
> > 5. resume from here (by sitemap-catching the deliveryUrl
> continuation id,
> > continuing the flowscript execution)
> >
> >
> > Is this possible? I tried to read
> > http://cocoon.apache.org/2.1/userdocs/flow/api.html on how creating
> > WebContinuations manually affect execution, but it doesn't say
> how and if I
> > could halt execution.
>
> What you need is a 'redirectAndWait'. This is something that IMHO
> is missing
> in the current flow API, but very easy to implement. I don't have
> the cocoon
> source here at the moment, but take a look at the
> 'sendPageAndWait' method in
> the flow implementation you are using (probably javascript). This method
> should call 'sendPage' and some other stuff. The
> 'redirectAndWait' method you
> need will contain a 'redirect' (or is it 'redirectTo'?) and this
> other stuff.
> That's all you need.
>
> A custom flow engine I'm working on as an example:
>public void sendPageAndWait(String uri, Object bizdata) {
>  sendPage(uri, bizdata);
>  getCont().endExecution(null);
>}
>
>public void redirectAndWait(String uri) {
>  redirectTo(uri);
>  getCont().endExecution(null);
>}
>
> Good luck,
> Emond

Looking at
cocoon\build\cocoon-2.1.5.1\classes\org\apache\cocoon\components\flow\javasc
ript\fom\fom_system.js, the sendPageAndWait method is really a sendPage call
with some extra stuff, just like you said:

FOM_Cocoon.suicide = new Continuation();

FOM_Cocoon.prototype.sendPageAndWait = function(uri, bizData, fun, ttl) {
this.sendPage(uri, bizData,
  new FOM_WebContinuation(new Continuation(),
  this.continuation, ttl));
if (fun) {
if (!(fun instanceof Function)) {
throw "Expected a function instead of: " + fun;
}
fun();
}
FOM_Cocoon.suicide();
}

It seems it's FOM_Cocoon.suicide(); that halts execution (duh). I tried
using this:

function testingSome() {

var c = cocoon.createWebContinuation();
print("Continuation = " + c.id);
FOM_Cocoon.suicide();
print("Continued executing.");
}

When I call this test method, it displays a continuation id and then halts.
When I call the continuation using the print'ed continuation id to resume
execution, it seems it's picking up execution right after the
createWebContinuation() call, which means it only prints the "Continuation =
" again and then executes suicide - whereas I wanted it to pick up right
after its suicide line and print the "Continued executing." part.

I guess I'm supposed to use this in some other way, but I'm not that
familiar with flowscript. What am I doing wrong?

regards,
  Ulf Sahlin


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating and halting flow continuations

2004-09-09 Thread Emond Papegaaij
On Thursday 09 September 2004 12:37, Ulf Sahlin wrote:
> > What you need is a 'redirectAndWait'. 
>
> Looking at fom_system.js, the sendPageAndWait method is really a sendPage
> call with some extra stuff, just like you said:
>
> FOM_Cocoon.suicide = new Continuation();
>
> FOM_Cocoon.prototype.sendPageAndWait = function(uri, bizData, fun, ttl) {
> this.sendPage(uri, bizData,
>   new FOM_WebContinuation(new Continuation(),
>   this.continuation, ttl));

> FOM_Cocoon.suicide();
> }
>
> It seems it's FOM_Cocoon.suicide(); that halts execution (duh). I tried
> using this:
>
> function testingSome() {
>
> var c = cocoon.createWebContinuation();
> print("Continuation = " + c.id);
> FOM_Cocoon.suicide();
> print("Continued executing.");
> }

This will not work indeed. cocoon.createWebContinuation() will create a new 
continuation that will resume directly after the point of creation. You could 
try something like this:

function redirectAndWait(uri, ttl) {
  var cont = new FOM_WebContinuation(new Continuation(),
 cocoon.continuation, ttl));
  cocoon.redirectTo(formatUri(uri, cont));
  FOM_Cocoon.suicide();
}

But I don't know where the 'Continuation()' comes from. Before I switched to 
my new flow engine I used to create a WebContinuation with 
'cocoon.createWebContinuation()' and check the request parameters to see if 
it's before or after the redirect:

function testingSome(uri) {
  var c = cocoon.createWebContinuation();
  print("Continuation = " + c.id);
  if (cocoon.request.get("afterRedirect") == null) {
cocoon.redirectTo(uri);
  } else {
print("Continued executing.");
  }
}

This way you have to make sure the user is redirected to the page with 
'afterRedirect' set (to 'true' for example). I think this way is less 
elegant, because the excution of the flow continuous after the redirect.

Emond

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating and halting flow continuations

2004-09-09 Thread Ulf Sahlin
Hi!

> > It seems it's FOM_Cocoon.suicide(); that halts execution (duh). I tried
> > using this:
> >
> > function testingSome() {
> >
> > var c = cocoon.createWebContinuation();
> > print("Continuation = " + c.id);
> > FOM_Cocoon.suicide();
> > print("Continued executing.");
> > }
>
> This will not work indeed. cocoon.createWebContinuation() will
> create a new
> continuation that will resume directly after the point of
> creation. You could
> try something like this:
>
> function redirectAndWait(uri, ttl) {
>   var cont = new FOM_WebContinuation(new Continuation(),
>  cocoon.continuation, ttl));
>   cocoon.redirectTo(formatUri(uri, cont));
>   FOM_Cocoon.suicide();
> }
>

I don't think I can use this solution, since I need to know the continuation
id beforehand I do the actual redirect (to be used in step 2: "put the id of
the continuation in a deliveryUrl").



> But I don't know where the 'Continuation()' comes from. Before I
> switched to
> my new flow engine I used to create a WebContinuation with
> 'cocoon.createWebContinuation()' and check the request parameters
> to see if
> it's before or after the redirect:
>
> function testingSome(uri) {
>   var c = cocoon.createWebContinuation();
>   print("Continuation = " + c.id);
>   if (cocoon.request.get("afterRedirect") == null) {
> cocoon.redirectTo(uri);
>   } else {
> print("Continued executing.");
>   }
> }
>
> This way you have to make sure the user is redirected to the page with
> 'afterRedirect' set (to 'true' for example). I think this way is less
> elegant, because the excution of the flow continuous after the redirect.

This probably works, I'll look into it.

Regards,
  Ulf Sahlin


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]