cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <s.gia...@thebug.it>
Subject Re: Flowscript continuation from external reply
Date Tue, 21 Feb 2006 13:11:10 GMT
Hi Andrew,
first question. When you say "pass variables to an external site" you 
mean "redirect the user to an external site, like a payment gateway, and 
then the external site will redirect the user back to me" right?

In that case, the redirectTo function does not suspend the current 
execution, and there is no "redirectAndWait" function, so you are 
sending the user to the site, but the flow is not waiting for the response.

You can solve in two ways :

1) Instead of using redirectTo, set up a page with a link to the 
external site (like a jx page), then use sendPageAndWait to send this 
page to the user, he will click on the link, go to the external site and 
all the rest, while your flow will be suspended until the external site 
will redirect him to your continuation and the flow will restart. This 
is a clean solution, but involves one more step for the user.

2) Create a webContinuation in your flow (you can do this in javascript 
flow), before the redirectTo. This way you have a "bookmark" in your 
flow the user can be redirected to, even if you haven't stopped the flow 
directly. This is quite a dirtier solution, but avoids the extra click. 
Here is the pseudocode:

continuation = createWebcontinuation();
if (value-returned == null) {
    redirectTo(externalSite + continuation.id);
} else {
    if (value-returned == true) {
       etc etc
    }
}

You have to check if there is a returned value because when the user is 
redirected back to your site the flow will restart from the line 
immediately after the creation of the continuation, so you have no way 
to determine if this is the first time the user is entering this flow  
or if it's returning from the external site if not checking for the 
presence of the return value.

Hope this helps,
Simone

Andrew Madu wrote:

> Hi,
> I have a flowscript function which passes some variables to an 
> external site. The site will send back a success or failure 
> confirmation based upon the parameters passed. What I want to do next 
> is continue on the from the next point in time after the external site 
> was contacted, so:
>
> I want to create some flowscript which passes variables to an external 
> site, (https://www.externalsite.com/test.asp?contiuation-id=xxx, 
> var1=x,var2=x) for example, gets a response back from the external 
> site (http://www.mysite.com/continuation-id/value-returned), and based 
> on the response sent back does something else following the initial 
> call to the external site. How do I do this in flowscript? 
>
> So what i'm thinking is something like:
>
> function getResults() {
>
> cocoon.redirectTo("https://www.externalsite.com/test.asp?contiuation-id=xxx, 
> var1=x,var2=x")
>
> if (value-returned == 'true') {
> do this
> }else{
> do this
> }
> }
>
> How do I get back to the point after cocoon.redirectTo() using the 
> returned continuation-id?
>
> thanks in advance
>
> Andrew

-- 
Simone Gianni

Mime
View raw message