As long as you prevent the browser from caching the page with the form (just
the page itself, caching the resources is fine) then when the user hits back
wicket will pull the old page instance from the pagemap and rerender it. That
page instance is the same one that was used the first time, so its state will
still be the same. Just set some flag when the user submits, and also check
that flag when processing the form like this:
onSubmit(...) {
if (!submitted) {
submitted = true;
// do some stuff....
} else {
// redirect to another page
}
}
Wicket does set some cache headers, but to disable it in FF we had to set 1
extra header. If you check the setHeaders method in WebPage you'll see that
they set 3 headers I think and then there is one other header (must
revalidate?) that they have commented out. That commented header did the trick
for us. As for the redirect, you might be able to pull the 'last valid page'
as you call it from the page map, not sure though.
Craig
----- Original Message -----
From: Sergey Olefir
[mailto:[email protected]]
To: [email protected]
Sent: Tue, 06 Apr
2010 06:32:35 -0400
Subject: What happens after browser's 'back' button?
> Hi,
>
> our first Wicket-based application is about to go into testing and I'm
> feeling rather uncomfortable about the fact that I don't really
> understand what happens when user uses browser's back button and then
> submits some 'outdated' form. Can someone elaborate please on what
> exactly happens when Wicket receives submit from the 'old' page?
>
> On a more specific note, I will most probably need to block user from
> submitting the same form more than once. E.g.:
>
> - If I wanted to prevent user from using back button at all, how would
> I determine that the incoming submit is from the 'old' page?
>
> - If I determined that Wicket received submit from the 'old' page, how
> would I send user back to the last 'valid' page they were on?
>
> - If I wanted to detect that user submits the same form twice (without
> necessarily blocking the back button in all cases), how would I go
> about it? I suppose I could store something in Session to track which
> forms were already submitted?
>
> P.S. Sorry for kind of 'reposting' my previous question, but I'm
> running out of time on this project and really would love to
> understand how to properly handle browser's 'back' button...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]