From: Sylvain Wallez
> Christopher Oliver wrote:
>
> > I think you're making this much more complicated than it
> needs to be.
> > Please look at how JXForms does this. First it creates a
> continuation
> > immediately before and immediately after a page is sent to the
> > browser. The latter continuation behaves exactly like
> > sendPageAndWait(). However, by invoking the former you
> cause the page
> > to be resent (and processing to restart when that page is
> > resubmitted). So:
> >
> > 1) If you invoke the current continuation processing continues after
> > the current page is submitted.
> > 2) If you invoke its parent continuation the current page
> is resent to
> > the browser.
> > 3) If you invoke the grandparent continuation the actions following
> > submission of the previous page are replayed.
> > 4) If you invoke the great-grandparent continuation the
> previous page
> > is resent to the browser.
> >
> > So to implement the "back" button, you invoke (4).
> >
> > The idea is that instead of only encoding the continuation id in the
> > form or request url, you also associate a "forward" or
> "back" action
> > with the submit button. The form submits are _always_
> submitted to the
> > same location, where some Java or JavaScript code looks at the
> > continuation id together with "forward" or "back" indication of the
> > submit button. If the indication is "forward" then you
> simply look up
> > the continuation associated with the continuation id and invoke it.
> > But if the indication is "back" then you invoke the
> great-grandparent
> > of the continuation.
>
>
> I'll look more closely to JXForms. However, does the above
> behaviour fit
> with the fact that form.showForm() creates several continuations when
> iterating until the form is valid? In that case, we cannot
> just consider
> restarting at the n-2th or n-3th continuations, since intermediate
> continuations may have occured inbetween...
I think Chris means this (out of the JXForms example):
JXForm.prototype.sendView = function(uri, validator) {
var lastWebCont = this.lastWebContinuation;
// create a continuation, the invocation of which will resend
// the page: this is used to implement <xf:submit
continuation="back">
var wk = this.start(lastWebCont);
while (true) {
this.removeForm();
this.saveForm();
var thisWebCont = this._sendView(uri, wk);
// _sendView creates a continuation, the invocation of which
// will return right here: it is used to implement
// <xf:submit continuation="forward">
this.populateForm();
var phase = cocoon.request.getAttribute("jxform-submit-phase");
if (validator != undefined) {
validator(this);
}
this.validateForm(phase);
if (!this.hasViolations()) {
this.lastWebContinuation = thisWebCont;
break;
}
}
}
>
> > With this approach your example reduces to this (and most
> importantly
> > you don't have to explicitly code back/forward navigation
> in your flow
> > script):
> >
> > function myWizard() {
> > var wizard = new Wizard("wizard-spec.xml");
> > wizard.show("first-page.html");
> > wizard.show("second-page.html");
> > wizard.show("third-page.html");
> > cocoon.sendPage("finished.html");
> > }
>
>
> Mmmh... what I don't like above is that the wizard is sending
> the pages.
> How can we with this approach mix form.showForm and
> cocoon.sendPageAndWait in the same wizard-style interaction?
What do you mean here? Can you give an example of your use case?
Reinhard