Re: [Flow] Going back and forth with continuations

2002-12-16 Thread Ovidiu Predescu

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: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]



Re: [Flow] Going back and forth with continuations

2002-12-16 Thread Christopher Oliver
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.

Regards,

Chris


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



Re: [Flow] Going back and forth with continuations

2002-12-16 Thread Ovidiu Predescu

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.

What's this suicide() function? I don't find it defined anywhere.


It's a continuation object created by callFunction(), the entry point 
in the control flow. 'suicide' is the continuation of the 
callFunction(), which does nothing else than return the control to the 
sitemap, which invoked callFunction(). 'suicide' is called by the 
blocking sendPage() to return the control to the sitemap, after the 
continuation of sendPage() has been stored away.

Best regards,
Ovidiu


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



Re: [Flow] Going back and forth with continuations

2002-12-15 Thread Ugo Cei
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? What's this suicide() function? I don't 
find it defined anywhere.

	Ugo

--
Ugo Cei - http://www.beblogging.com/blog/


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



Re: [Flow] Going back and forth with continuations

2002-12-15 Thread Ovidiu Predescu

On Saturday, Dec 14, 2002, at 12:33 US/Pacific, Ugo Cei wrote:


Christopher Oliver wrote:


In this case to go back to the beginning you don't need a 
continuation. You can just call the function again.

Which wouldn't work if you have some code at the beginning of the 
function that is to be executed only once.

This is true. It also won't work if you plan to keep the value of the 
local variables, since calling the function will start with a fresh set 
of values for them.

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
  ...
  sendPage("1.xml");

  sendPage("2.xml");
}

The parent continuation of the first sendPage() is now the one defined 
by startForm(), so referring to the previous continuation now makes 
sense.

I think this solves the problem you mention.

Regards,
Ovidiu


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



Re: [Flow] Going back and forth with continuations

2002-12-14 Thread Ugo Cei
Ovidiu Predescu wrote:

The value "2" for the "select" attribute is because it looks like 
using "1" actually refers to the "current" continuation and not the 
"previous" one as I thought initially. Am I correct and is this a 
"feature" or a "bug"?


I don't see how "1" could refer to the current continuation. Both in 
jpath.xsl and in WebContinuation.java, "0" refers to the current 
continuation. Could you please post the relevant code which exhibits the 
problem?

Maybe my terminology wasn't appropriate. What I meant to say is that by 
invoking continuation #0, you go to the "next" page in a sequence of 
pages. By invoking continuation #1 you go to the "current" page, the one 
you're currently viewing. By invonking continuation #2 you go to the 
"previous" page. Is this correct and expceted?

Embedding a "submit" and "prev" button in any of the "showform" or 
"askforconfirmation" pages should be as simple as doing 
 and  respectively. 
If this doesn't work, there's a bug in the flow code that handles this.

No, you must use select="2" to go to the previous page, and after all 
this makes sense.

The problem still remains that you cannot go back to the first page in 
the sequence.

	Ugo



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



Re: [Flow] Going back and forth with continuations

2002-12-14 Thread Ugo Cei
Christopher Oliver wrote:


In this case to go back to the beginning you don't need a continuation. 
You can just call the function again.

Which wouldn't work if you have some code at the beginning of the 
function that is to be executed only once.

	Ugo




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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Ovidiu Predescu

On Friday, Dec 13, 2002, at 21:46 US/Pacific, Christopher Oliver wrote:


Ugo Cei wrote:


I've tried to implement this use case in a flowscript like the 
following:

function foobar() {
  // Note the use of the "new style" function names
  sendPageAndWait("showform", {});
  // Collect request parameters here
  sendPageAndWait("askforconfirmation", { /* ... field values ... */ 
});
  sendPage("thankyou", {});
}

In the initial form and the confirmation page, I use forms with an 
action of "kont(" +  + ")".


Anyway, that's not a big issue. The big issue is that it does not 
seem possible to use a continuation to go back to the first form. My 
understanding is that the first continuation is created, so to say, 
*after* the first "sendPageAndWait", so there's no state saved before 
the first form is shown.

In this case to go back to the beginning you don't need a 
continuation. You can just call the function again.

Ah, good point, I misunderstood Ugo's original message. Sorry for the 
confusion, Chris is definitely right here!

Ovidiu


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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Ovidiu Predescu
Hi Ugo,

On Friday, Dec 13, 2002, at 08:18 US/Pacific, Ugo Cei wrote:


Dear flow gurus,

suppose I have an application that implements the following workflow:

1. Present the user a form to be filled.

2. When the user submits the form, present him a confirmation page, 
with two buttons: "Confirm" and "Go back"

3a. If the user presses "Confirm", perform some job (e.g. save form 
field values to a database) and show a "thank you" page.

3b. If the user presses "Go back", go to step 1.

I've tried to implement this use case in a flowscript like the 
following:

function foobar() {
  // Note the use of the "new style" function names
  sendPageAndWait("showform", {});
  // Collect request parameters here
  sendPageAndWait("askforconfirmation", { /* ... field values ... */ 
});
  sendPage("thankyou", {});
}

In the initial form and the confirmation page, I use forms with an 
action of "kont(" +  + ")".

In the confirmation page, I implement the "Go back" with a link to the 
following URI: "kont(" +  + ")".

The value "2" for the "select" attribute is because it looks like 
using "1" actually refers to the "current" continuation and not the 
"previous" one as I thought initially. Am I correct and is this a 
"feature" or a "bug"?

I don't see how "1" could refer to the current continuation. Both in 
jpath.xsl and in WebContinuation.java, "0" refers to the current 
continuation. Could you please post the relevant code which exhibits 
the problem?

Anyway, that's not a big issue. The big issue is that it does not seem 
possible to use a continuation to go back to the first form. My 
understanding is that the first continuation is created, so to say, 
*after* the first "sendPageAndWait", so there's no state saved before 
the first form is shown.

The first continuation is created and an id associated with it right at 
the moment you send the first page. That's how you can embed a link to 
it in "showform" or "askforconfirmation".

If this is indeed the case, how do you propose to implement this use 
case with Flow? At the moment, I have resorted to using a link of the 
kind  but I don't 
really like this solution. I could also use a loop, test a request 
parameter from the confirmation form and use it to decide between 
doing a "break" or a "continue", but I don't like it either.

Embedding a "submit" and "prev" button in any of the "showform" or 
"askforconfirmation" pages should be as simple as doing 
 and  
respectively. If this doesn't work, there's a bug in the flow code that 
handles this.

Could you please post or send the sources privately so I can take a 
look at them?

Regards,
Ovidiu


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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Christopher Oliver

Konstantin Piroumian wrote:


From: "Ugo Cei" <[EMAIL PROTECTED]>
 

It seems to me that Christian's version is more correct conceptually, it
allows to perform additional actions when user clicks "Go back", while in
your version the flow engine will automatically return the flow to the
pervious state.

E.g. in most cases when users click "Go back" button they wish to correct
mistakes in the data they have entered, so you have to display not the empty
form, but the form with the data that the user has entered. Will the "-1"
(or "1") flow step retain the filled data in the form? I suspect that won't.
In the above version of the script it would be easy to implement.

The filled data is retained, even when you invoke a continuation. The 
continuation just restores the program counter, it doesn't roll back 
changes to other data.



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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Christopher Oliver
Ugo Cei wrote:


I've tried to implement this use case in a flowscript like the following:

function foobar() {
  // Note the use of the "new style" function names
  sendPageAndWait("showform", {});
  // Collect request parameters here
  sendPageAndWait("askforconfirmation", { /* ... field values ... */ });
  sendPage("thankyou", {});
}

In the initial form and the confirmation page, I use forms with an 
action of "kont(" +  + ")".


Anyway, that's not a big issue. The big issue is that it does not seem 
possible to use a continuation to go back to the first form. My 
understanding is that the first continuation is created, so to say, 
*after* the first "sendPageAndWait", so there's no state saved before 
the first form is shown.

In this case to go back to the beginning you don't need a continuation. 
You can just call the function again.


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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Konstantin Piroumian
From: "Ugo Cei" <[EMAIL PROTECTED]>
> Christian Haul wrote:
> > Interesting. Why not:
> >
> >  function foobar() {
> >// Note the use of the "new style" function names
> >var response = null;
> >do {
> >sendPageAndWait("showform", {});
> >// Collect request parameters here
> >sendPageAndWait("askforconfirmation", { /* ... field values ...
*/ });
> >response = input("request-param","confirm"); // or
request.getParameter("confirm");
> >} while (response == null);
> >sendPage("thankyou", {});
> >  }
>
> Because I'd find it nicer and more elegant not having to rely on an
> extra variable or parameter and use a loop. Continuations are so nice ;-).

Disclaimer: I'm not a flow-script/continuations guru, so please correct me
if I'm wrong.

It seems to me that Christian's version is more correct conceptually, it
allows to perform additional actions when user clicks "Go back", while in
your version the flow engine will automatically return the flow to the
pervious state.

E.g. in most cases when users click "Go back" button they wish to correct
mistakes in the data they have entered, so you have to display not the empty
form, but the form with the data that the user has entered. Will the "-1"
(or "1") flow step retain the filled data in the form? I suspect that won't.
In the above version of the script it would be easy to implement.

But Ugo's approach has another advantage in case when you don't know where
the user came from and you really move him back to the previous form, just
like you do it using window.back().

If it's possible to perform additional actions when the flow is continued
from a historical point then probably the two approaches could be combined.

Konstantin

>
> Ugo
>
> --
> Ugo Cei - http://www.beblogging.com/blog/
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>


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




Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Ugo Cei
Christian Haul wrote:

Interesting. Why not:

 function foobar() {
   // Note the use of the "new style" function names
   var response = null;
   do {
   sendPageAndWait("showform", {});
   // Collect request parameters here
   sendPageAndWait("askforconfirmation", { /* ... field values ... */ });
   response = input("request-param","confirm"); // or request.getParameter("confirm");
   } while (response == null);
   sendPage("thankyou", {});
 }


Because I'd find it nicer and more elegant not having to rely on an 
extra variable or parameter and use a loop. Continuations are so nice ;-).

	Ugo

--
Ugo Cei - http://www.beblogging.com/blog/


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



Re: [Flow] Going back and forth with continuations

2002-12-13 Thread Christian Haul
On 13.Dec.2002 -- 05:18 PM, Ugo Cei wrote:
> Dear flow gurus,
> 
> suppose I have an application that implements the following workflow:
> 
> 1. Present the user a form to be filled.
> 
> 2. When the user submits the form, present him a confirmation page, with 
> two buttons: "Confirm" and "Go back"
> 
> 3a. If the user presses "Confirm", perform some job (e.g. save form 
> field values to a database) and show a "thank you" page.
> 
> 3b. If the user presses "Go back", go to step 1.
> 
> I've tried to implement this use case in a flowscript like the following:
> 
> function foobar() {
>   // Note the use of the "new style" function names
>   sendPageAndWait("showform", {});
>   // Collect request parameters here
>   sendPageAndWait("askforconfirmation", { /* ... field values ... */ });
>   sendPage("thankyou", {});
> }
> 
> In the initial form and the confirmation page, I use forms with an 
> action of "kont(" +  + ")".
> 
> In the confirmation page, I implement the "Go back" with a link to the 
> following URI: "kont(" +  + ")".

Interesting. Why not:

 function foobar() {
   // Note the use of the "new style" function names
   var response = null;
   do {
   sendPageAndWait("showform", {});
   // Collect request parameters here
   sendPageAndWait("askforconfirmation", { /* ... field values ... */ });
   response = input("request-param","confirm"); // or 
request.getParameter("confirm");
   } while (response == null);
   sendPage("thankyou", {});
 }

Chris.
-- 
C h r i s t i a n   H a u l
[EMAIL PROTECTED]
fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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