You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mfs <fa...@gmail.com> on 2007/11/18 04:44:52 UTC

double form submission handling ?

Guys,

Yet another question...

Does wicket handles double form submission in anyway ? like if the user
clicks the back button where the previous page was a result of a form
submission, which could result in double form submission..OR otherwise
refreshes that page..

Farhan.


-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13816084
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by saenz <ls...@mac.com>.
Cool! I guess I just didn't realize that it is OK to store state in your own
instance of Form like your example below.

Thanks for the answer --



igor.vaynberg wrote:
> 
> class myform extends form {
>  private boolean submitted=false;
> 
>  protected abstract void oninitialsubmit();
>  protected abstract void onresubmit();
> 
>   protected final void onsubmitted() {
>      if (!submitted) oninitialsubmit(); else onresubmit();
>      submitted=true;
>   }
> }
> 
> why does wicket need a special mechanism?
> 
> 
> On Nov 19, 2007 6:57 PM, saenz <ls...@mac.com> wrote:
>>
>> I agree -- I had a question about this very topic. I was going to ask:
>>
>> Does Wicket have any mechanism to notify the application that a form from
>> a
>> previous page has been re-submitted (the situation you describe below)?
>>
>> This is so that the application can decide what to do -- in some cases,
>> the
>> best action might be to ignore the re-submission; in other cases, it
>> might
>> be correct to handle it the same way as the initial submission.
>>
>> Example: In the Form.onSubmit() or the Button.onSubmit() method, is there
>> was a way to get the Page context (including the version) so that the
>> application to find out if the request is coming from an older version of
>> the page (and therefore must be due to a back-button navigation followed
>> by
>> a form re-submit)?
>>
>>
>> Johan Compagner wrote:
>> >
>> > But a user can click the back button to go to the previous page with
>> > the form and submit it again, but that isn't something wicket should
>> > prevent.  Because that could be valid for that application, a user
>> > submit something then sees it made a mistake, presses back, corrects
>> > it and submit again..
> 
-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13851026
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Igor Vaynberg <ig...@gmail.com>.
class myform extends form {
 private boolean submitted=false;

 protected abstract void oninitialsubmit();
 protected abstract void onresubmit();

  protected final void onsubmitted() {
     if (!submitted) oninitialsubmit(); else onresubmit();
     submitted=true;
  }
}

why does wicket need a special mechanism?

-igor


On Nov 19, 2007 6:57 PM, saenz <ls...@mac.com> wrote:
>
> I agree -- I had a question about this very topic. I was going to ask:
>
> Does Wicket have any mechanism to notify the application that a form from a
> previous page has been re-submitted (the situation you describe below)?
>
> This is so that the application can decide what to do -- in some cases, the
> best action might be to ignore the re-submission; in other cases, it might
> be correct to handle it the same way as the initial submission.
>
> Example: In the Form.onSubmit() or the Button.onSubmit() method, is there
> was a way to get the Page context (including the version) so that the
> application to find out if the request is coming from an older version of
> the page (and therefore must be due to a back-button navigation followed by
> a form re-submit)?
>
>
> Johan Compagner wrote:
> >
> > But a user can click the back button to go to the previous page with
> > the form and submit it again, but that isn't something wicket should
> > prevent.  Because that could be valid for that application, a user
> > submit something then sees it made a mistake, presses back, corrects
> > it and submit again..
> >
> --
> View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13850026
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by saenz <ls...@mac.com>.
I agree -- I had a question about this very topic. I was going to ask:

Does Wicket have any mechanism to notify the application that a form from a
previous page has been re-submitted (the situation you describe below)?

This is so that the application can decide what to do -- in some cases, the
best action might be to ignore the re-submission; in other cases, it might
be correct to handle it the same way as the initial submission.

Example: In the Form.onSubmit() or the Button.onSubmit() method, is there
was a way to get the Page context (including the version) so that the
application to find out if the request is coming from an older version of
the page (and therefore must be due to a back-button navigation followed by
a form re-submit)?


Johan Compagner wrote:
> 
> But a user can click the back button to go to the previous page with
> the form and submit it again, but that isn't something wicket should
> prevent.  Because that could be valid for that application, a user
> submit something then sees it made a mistake, presses back, corrects
> it and submit again..
> 
-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13850026
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Johan Compagner <jc...@gmail.com>.
>
> > Or is the only way to prevent the double-submit problem to use the
> > REDIRECT_TO_RENDER or REDIRECT_TO_BUFFER options (and therefore require
> > sticky load balancing)?
>
> No, you can do whatever you like. Note that redirect-to-render should
> work in a clustered environment as well, but would increase the load
> quite a bit. The main reason for it's existence is to support
> portlets. At least, that's how it got introduced.
>

And the increase in load is because the second redirect request needs to
completely
repopulate your page (creating a new hibernate session or that kind of
stuff)
And people don't expect that when they do:

setResponsePage(new Page())

that that page is populated twice (everything they do in the constructor)
and when the redirect happens. So because of that we have redirect to buffer
that means that the complete handling of the first request and the real
response page
is done in 1 go. But yes that strategy only works with sticky sessions.

johan

Re: double form submission handling ?

Posted by Eelco Hillenius <ee...@gmail.com>.
> > Sure. Use custom solutions, like the one Igor suggested.
> >
> I think I understand -- we can use exactly the same solution to the form
> re-submit problem in the case of [a back-button navigation followed by a
> form re-post] to solve the double-submit problem in the case of [a page
> refresh after a form post when ONE_PASS_RENDER is being used].
>
> In both cases, if we subclass Form and hold state to track whether the form
> has already been submitted once before, we can handle the problem the way
> Igor suggested previously. Is that correct?

Yep, that sounds like a good option.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by saenz <ls...@mac.com>.


Eelco Hillenius wrote:
> 
>> Lets say that we wanted to do "sophisticated clustering", so we use the
>> ONE_PASS_RENDER option. However, we still want to avoid the double-submit
>> problem. Is it possible? Is there a way the application can prevent it
>> from
>> happening in this case?
> 
> Sure. Use custom solutions, like the one Igor suggested.
> 

I think I understand -- we can use exactly the same solution to the form
re-submit problem in the case of [a back-button navigation followed by a
form re-post] to solve the double-submit problem in the case of [a page
refresh after a form post when ONE_PASS_RENDER is being used].

In both cases, if we subclass Form and hold state to track whether the form
has already been submitted once before, we can handle the problem the way
Igor suggested previously. Is that correct?
-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13860852
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Eelco Hillenius <ee...@gmail.com>.
> Lets say that we wanted to do "sophisticated clustering", so we use the
> ONE_PASS_RENDER option. However, we still want to avoid the double-submit
> problem. Is it possible? Is there a way the application can prevent it from
> happening in this case?

Sure. Use custom solutions, like the one Igor suggested.

> Or is the only way to prevent the double-submit problem to use the
> REDIRECT_TO_RENDER or REDIRECT_TO_BUFFER options (and therefore require
> sticky load balancing)?

No, you can do whatever you like. Note that redirect-to-render should
work in a clustered environment as well, but would increase the load
quite a bit. The main reason for it's existence is to support
portlets. At least, that's how it got introduced.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by saenz <ls...@mac.com>.

Eelco Hillenius wrote:
> 
> On Nov 18, 2007 2:55 AM, mfs <fa...@gmail.com> wrote:
>>
>> Yeah that scenario still makes sense where the user goes to the form page
>> itself, but i was refering to the scenario where the user goes to the
>> page
>> (with the back button) which got shown after form submission, as in that
>> case the browser would be submitting the request to the server
>> (implicitly
>> in case of a GET) and hence a double form submit OR the other scenario
>> where
>> user presses the refresh button on that previous page.
> 
> That doesn't happen with redirect-after-post.
> 
> Eelco
> 

I read the javadoc for IRequestCycleSettings -- I have a question about it:

Lets say that we wanted to do "sophisticated clustering", so we use the
ONE_PASS_RENDER option. However, we still want to avoid the double-submit
problem. Is it possible? Is there a way the application can prevent it from
happening in this case?

Or is the only way to prevent the double-submit problem to use the
REDIRECT_TO_RENDER or REDIRECT_TO_BUFFER options (and therefore require
sticky load balancing)?
-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13851209
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Eelco Hillenius <ee...@gmail.com>.
On Nov 18, 2007 2:55 AM, mfs <fa...@gmail.com> wrote:
>
> Yeah that scenario still makes sense where the user goes to the form page
> itself, but i was refering to the scenario where the user goes to the page
> (with the back button) which got shown after form submission, as in that
> case the browser would be submitting the request to the server (implicitly
> in case of a GET) and hence a double form submit OR the other scenario where
> user presses the refresh button on that previous page.

That doesn't happen with redirect-after-post.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by mfs <fa...@gmail.com>.
Yeah that scenario still makes sense where the user goes to the form page
itself, but i was refering to the scenario where the user goes to the page
(with the back button) which got shown after form submission, as in that
case the browser would be submitting the request to the server (implicitly
in case of a GET) and hence a double form submit OR the other scenario where
user presses the refresh button on that previous page.

Farhan.


Johan Compagner wrote:
> 
> But a user can click the back button to go to the previous page with
> the form and submit it again, but that isn't something wicket should
> prevent.  Because that could be valid for that application, a user
> submit something then sees it made a mistake, presses back, corrects
> it and submit again..
> 
> 2007/11/18, Eelco Hillenius <ee...@gmail.com>:
>> > Yet another question...
>> >
>> > Does wicket handles double form submission in anyway ? like if the user
>> > clicks the back button where the previous page was a result of a form
>> > submission, which could result in double form submission..OR otherwise
>> > refreshes that page..
>>
>> Yes, Wicket by default uses the redirect after submit pattern. See the
>> renderStrategy property of IRequestCycleSettings (read the Javadoc of
>> the three available strategies).
>>
>> Eelco
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/double-form-submission-handling---tf4829048.html#a13818039
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Johan Compagner <jc...@gmail.com>.
But a user can click the back button to go to the previous page with
the form and submit it again, but that isn't something wicket should
prevent.  Because that could be valid for that application, a user
submit something then sees it made a mistake, presses back, corrects
it and submit again..

2007/11/18, Eelco Hillenius <ee...@gmail.com>:
> > Yet another question...
> >
> > Does wicket handles double form submission in anyway ? like if the user
> > clicks the back button where the previous page was a result of a form
> > submission, which could result in double form submission..OR otherwise
> > refreshes that page..
>
> Yes, Wicket by default uses the redirect after submit pattern. See the
> renderStrategy property of IRequestCycleSettings (read the Javadoc of
> the three available strategies).
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: double form submission handling ?

Posted by Eelco Hillenius <ee...@gmail.com>.
> Yet another question...
>
> Does wicket handles double form submission in anyway ? like if the user
> clicks the back button where the previous page was a result of a form
> submission, which could result in double form submission..OR otherwise
> refreshes that page..

Yes, Wicket by default uses the redirect after submit pattern. See the
renderStrategy property of IRequestCycleSettings (read the Javadoc of
the three available strategies).

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org