Tobia Conforto wrote:
Hello

I'm trying to implement in Cocoon a somewhat standard web behaviour: at the end of a form (final POST request, form fully validated, etc.) I'd like to redirect the user to a GET request before showing him the final 'Thank you' page.

This is often done in web programming, so that in case the user reloads the result page, he will just reload the page itself, and not execute the form logic twice. The browsers use this interpretation too, by showing the user a warning "The form action will be executed again if you reload. Are you sure? Yes/No" when you try to reload a POST page.

I thought this would be easy to accomplish with continuations, but I'm hitting a strange bug. This is the utility function I'm calling from my flows, AFTER the form has been processed (DB inserts, emails sent, etc), just BEFORE doing the sendPage() with the result page:

function redirectToGet() {
    var done = false;
    var cont = cocoon.createWebContinuation();
    if (! done) {
        done = true;
        cocoon.redirectTo('/cont=' + cont.id, true);
        cocoon.exit();
    }
}

The problem is:

- if I leave out the cocoon.exit(), I get:
IllegalStateException: Pipeline has already been processed for this request

- if I put the cocoon.exit() as shown, I get:
ProcessingException: Attempted to process incomplete pipeline

What gives?

I'm using Cocoon 2.1.10

I'm not sure about the specific errors you're getting, but here's how I accomplish the double-submit prevention:


var finished = false;
form.showForm(...);
if(!finished) {
   form.save(bean);
   myJavaService.doDatabaseUpdate(bean);
   finished = true;
}
cocoon.sendPage("confirmation-page");


So if the user reloads the confirmation page, the block that performs the database update will be skipped, and the confirmation page redisplayed. It's not a GET redirect, but performs the same function quite well. Sorry to not answer your specific question, but perhaps the alternate approach will help.

--Jason


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

Reply via email to