You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matthias Keller <ma...@ergon.ch> on 2011/01/25 18:14:29 UTC

How to remove all previous pages from pagemap

Hi List

We've got the following scenario:
After a user hopped through a wizard, he'll reach a confirmation page in 
our workflow. Now the session still needs to remain active but I want to 
prohibit going back into the wizard and resend it again.
I experimented with  Session.clear()  and  Session.getPageMaps() and 
calling pageMap.remove() on each instance returned, to no avail - after 
clicking back, the user may still access the wizard again.

What's the correct way to 'expire' *all* previous pages so that going 
back using the back-button is not possible anymore? And, where do I need 
to put that specific code (at the end of the wizard after calling 
setResponsePage(), in the onInitialize() of the confirmation page, ... ?

Is there some cool debugging feature or call I'd could do to see all the 
pages in the pagemaps with their versions et al in order to find out 
what to call to clear that...?

Thank you very much

Matt


Re: How to remove all previous pages from pagemap

Posted by rebecca <ri...@gmail.com>.
Hello,

Well i have to say that i spent hours yesterday trying to understand this.

It was exactly as Matthias described: On clicking the back button, wicket
goes to the server to fetch the page (which is o.k. - i asked browser not to
cache). But instead of rendering a new bookmarkable version of the page, it
rendered a wizard page that was stored in the server.

Nothing helped (getSession().clear(), getPageMap.clear()). Only Matt's
solution did the work (thanks Matt).

This scenario of a wizard page which redirects to a message page is a very
common one (and can't be defined as an ugly solution btw). Also, the need to
prevent the user from going back to a wizard he just completed is also very
common.

Do you precious wicketiers have added/found a solution to this need in
Wicket?

thanks
Rebecca


 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-remove-all-previous-pages-from-pagemap-tp3236570p3811843.html
Sent from the Users forum 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: How to remove all previous pages from pagemap

Posted by Matthias Keller <ma...@ergon.ch>.
On 2011-01-26 15:49, Martijn Dashorst wrote:
> On Wed, Jan 26, 2011 at 3:23 PM, Matthias Keller
> <ma...@ergon.ch>  wrote:
>> My current solution which solves this problem (although ugly) is the
>> following code in the onClick:
> You could try to see if "setRedirect(true);" works for you, and not
> perform a setResponsePage( new Page()), but rather do a
> setResponsePage(Page.class). However, that would make the confirmation
> page bookmarkable, something you probably don't want :)
>
> Ugly use case sometimes requires ugly code :-).. I don't think this is
> ugly, it performs each step you need explicitly. The use case to
> remove pages from the page map is not that common, so the story for
> doing that is not as nice.
>
> Perhaps something like a "@DontStoreInPageMap" annotation could be
> used. This would put the page in the session, ensuring you still have
> the stateful programming model and are able to work with the page as
> if it were a normal wicket page. But the page would not be put in the
> pagestore. I guess this would still work across clusters to support
> failover: the current page would still be stored in the session,
> making it available on all buddy nodes.
>
> Martijn
Hi Marijn

Thanks for your reply

Well, if the code's ugly or not is one side - the time required to get 
to that point is the other side - I spent hours trying to figure out why 
Session.clear() apparently does not work. To understand that, a lot of 
insight into Request Cycles, PageMaps and Render Strategies is necessary.
I'd very much welcome a hook to alter the render strategy just for the 
next page. setRedirect(true) does not change the strategy and is the 
default in the (default) REDIRECT_TO_BUFFER strategy: In this case the 
next page is rendered and stored, then the user is redirected to a new 
url (to solve the Reload-after-POST problem) - the new url only serves 
the previously cached HTML code and does not call any hooks on the page 
itself (because it doesn't even know about it, I guess).
So what I'd need would be a kind of setRedirect() which switches to 
REDIRECT_TO_RENDER.

Matt



Re: How to remove all previous pages from pagemap

Posted by Martijn Dashorst <ma...@gmail.com>.
On Wed, Jan 26, 2011 at 3:23 PM, Matthias Keller
<ma...@ergon.ch> wrote:
> My current solution which solves this problem (although ugly) is the
> following code in the onClick:

You could try to see if "setRedirect(true);" works for you, and not
perform a setResponsePage( new Page()), but rather do a
setResponsePage(Page.class). However, that would make the confirmation
page bookmarkable, something you probably don't want :)

Ugly use case sometimes requires ugly code :-).. I don't think this is
ugly, it performs each step you need explicitly. The use case to
remove pages from the page map is not that common, so the story for
doing that is not as nice.

Perhaps something like a "@DontStoreInPageMap" annotation could be
used. This would put the page in the session, ensuring you still have
the stateful programming model and are able to work with the page as
if it were a normal wicket page. But the page would not be put in the
pagestore. I guess this would still work across clusters to support
failover: the current page would still be stored in the session,
making it available on all buddy nodes.

Martijn

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


Re: How to remove all previous pages from pagemap

Posted by Matthias Keller <ma...@ergon.ch>.
I now found one way to clear all previous pages.
I guess the reason is the REDIRECT_TO_BUFFER strategy (or however it's 
called) which both processes a button's onClick() event AND the next 
page's full initialization+rendering in one request. Thus the previous 
page (where the button was) is marked as 'touched' in the Session as 
well - no matter when I clear all the pagemaps, the previous page will 
just be re-added at the end of the request.
My current solution which solves this problem (although ugly) is the 
following code in the onClick:

         // Make sure this page does NOT get stored at the end of the 
request
         getSession().untouch(getPage());
         // Clear all previous stored pages
         getSession().clear();

         // display the confirmation page
         setResponsePage(new ConfirmationPage(...));

I still hope there's a better solution but this works for now


Does anyone know if there's the possibility to override the 
REDIRECT_TO_BUFFER strategy for a certain redirect? This would also 
solve this problem as then the Session.clear() would be executed in the 
next request after the onClick()....

thanks

Matt

On 2011-01-25 18:14, Matthias Keller wrote:
> Hi List
>
> We've got the following scenario:
> After a user hopped through a wizard, he'll reach a confirmation page 
> in our workflow. Now the session still needs to remain active but I 
> want to prohibit going back into the wizard and resend it again.
> I experimented with  Session.clear()  and  Session.getPageMaps() and 
> calling pageMap.remove() on each instance returned, to no avail - 
> after clicking back, the user may still access the wizard again.
>
> What's the correct way to 'expire' *all* previous pages so that going 
> back using the back-button is not possible anymore? And, where do I 
> need to put that specific code (at the end of the wizard after calling 
> setResponsePage(), in the onInitialize() of the confirmation page, ... ?
>
> Is there some cool debugging feature or call I'd could do to see all 
> the pages in the pagemaps with their versions et al in order to find 
> out what to call to clear that...?
>
> Thank you very much
>
> Matt



Re: How to remove all previous pages from pagemap

Posted by Matthias Keller <ma...@ergon.ch>.
Hi Martijn

Yes I know that, but as I stated, it's still possible to reload that 
page and perform actions on it (they are *all* stateful pages) - I must 
know how I can suppress that. I don't care if the user goes back and 
sees the page from the cache but he mustn't be able to perform any 
actions on it which I could not avoid yet, my knowledge of the page 
store implementation is too shallow; I don't know why the user may still 
access the previous page even thought I issued a Session.clear() which 
will call IPageMap.clear() on all pagemaps... Maybe because it's the 
previous page and it cannot really be removed .. ?

Thanks for your input

Matt

On 2011-01-26 12:10, Martijn Dashorst wrote:
> Unless you completely invalidated the browser/client side cache of
> markup, people can still use the back button and will be presented
> with the markup as it was rendered at that time. It is not until the
> user performs an action at that page when wicket will try to retrieve
> the page from the page store. And only then will it see that the page
> is no longer available (provided the page was stateful, and the action
> URL is not targetting a stateless action) and present the user with
> page expired (or whatever you configured as the page expired page).
>
> Martijn
>
> On Wed, Jan 26, 2011 at 11:17 AM, Matthias Keller
> <ma...@ergon.ch>  wrote:
>> On 2011-01-25 18:20, Jeremy Thomerson wrote:
>>> On Tue, Jan 25, 2011 at 11:14 AM, Matthias Keller wrote
>>>> Hi List
>>>>
>>>> We've got the following scenario:
>>>> After a user hopped through a wizard, he'll reach a confirmation page in
>>>> our workflow. Now the session still needs to remain active but I want to
>>>> prohibit going back into the wizard and resend it again.
>>>> I experimented with  Session.clear()  and  Session.getPageMaps() and
>>>> calling pageMap.remove() on each instance returned, to no avail - after
>>>> clicking back, the user may still access the wizard again.
>>>>
>>>> What's the correct way to 'expire' *all* previous pages so that going
>>>> back
>>>> using the back-button is not possible anymore? And, where do I need to
>>>> put
>>>> that specific code (at the end of the wizard after calling
>>>> setResponsePage(), in the onInitialize() of the confirmation page, ... ?
>>>>
>>>   Have you looked at IPageMap#clear()?  I'm not 100% sure where you are
>>> able
>>> to put it.  I think you could put it just before calling setResponsePage.
>>>   Not after, though (since setResponsePage throws an exception that stops
>>> processing, your code wouldn't get called after it.)
>> Session.clear() does just this, it visits all pagemaps and calls clear() on
>> them. Though this seems to clear up some things (when I get all pagemaps
>> afterwards programmatically, they're gone), I can still go back with the
>> back button and reload the pages as often as I like.
>> BTW, setResponsePage() does not throw any exceptions (at least not for
>> 1.4.X), it just stores the nexxt page somewhere in the RequestCycle for
>> later usage.
>>
>> It would be great if someone with deeper pagemaps-knowledge could chime in
>> to find out the right place and way to clear all old pages...
>>
>>> Is there some cool debugging feature or call I'd could do to see all the
>>>> pages in the pagemaps with their versions et al in order to find out what
>>>> to
>>>> call to clear that...
>>> Add a dependency to wicket-devutils and then in your base page (hopefully
>>> you have a base page for all your pages), add a DebugBar.  That will have
>>> some links to the inspector, etc...
>> Thanks, I'll give it a shot this afternoon
>>
>> Matt
>>
>>
>
>



Re: How to remove all previous pages from pagemap

Posted by Martijn Dashorst <ma...@gmail.com>.
Unless you completely invalidated the browser/client side cache of
markup, people can still use the back button and will be presented
with the markup as it was rendered at that time. It is not until the
user performs an action at that page when wicket will try to retrieve
the page from the page store. And only then will it see that the page
is no longer available (provided the page was stateful, and the action
URL is not targetting a stateless action) and present the user with
page expired (or whatever you configured as the page expired page).

Martijn

On Wed, Jan 26, 2011 at 11:17 AM, Matthias Keller
<ma...@ergon.ch> wrote:
> On 2011-01-25 18:20, Jeremy Thomerson wrote:
>>
>> On Tue, Jan 25, 2011 at 11:14 AM, Matthias Keller wrote
>>>
>>> Hi List
>>>
>>> We've got the following scenario:
>>> After a user hopped through a wizard, he'll reach a confirmation page in
>>> our workflow. Now the session still needs to remain active but I want to
>>> prohibit going back into the wizard and resend it again.
>>> I experimented with  Session.clear()  and  Session.getPageMaps() and
>>> calling pageMap.remove() on each instance returned, to no avail - after
>>> clicking back, the user may still access the wizard again.
>>>
>>> What's the correct way to 'expire' *all* previous pages so that going
>>> back
>>> using the back-button is not possible anymore? And, where do I need to
>>> put
>>> that specific code (at the end of the wizard after calling
>>> setResponsePage(), in the onInitialize() of the confirmation page, ... ?
>>>
>>  Have you looked at IPageMap#clear()?  I'm not 100% sure where you are
>> able
>> to put it.  I think you could put it just before calling setResponsePage.
>>  Not after, though (since setResponsePage throws an exception that stops
>> processing, your code wouldn't get called after it.)
>
> Session.clear() does just this, it visits all pagemaps and calls clear() on
> them. Though this seems to clear up some things (when I get all pagemaps
> afterwards programmatically, they're gone), I can still go back with the
> back button and reload the pages as often as I like.
> BTW, setResponsePage() does not throw any exceptions (at least not for
> 1.4.X), it just stores the nexxt page somewhere in the RequestCycle for
> later usage.
>
> It would be great if someone with deeper pagemaps-knowledge could chime in
> to find out the right place and way to clear all old pages...
>
>> Is there some cool debugging feature or call I'd could do to see all the
>>>
>>> pages in the pagemaps with their versions et al in order to find out what
>>> to
>>> call to clear that...
>>
>> Add a dependency to wicket-devutils and then in your base page (hopefully
>> you have a base page for all your pages), add a DebugBar.  That will have
>> some links to the inspector, etc...
>
> Thanks, I'll give it a shot this afternoon
>
> Matt
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

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


Re: How to remove all previous pages from pagemap

Posted by Matthias Keller <ma...@ergon.ch>.
On 2011-01-25 18:20, Jeremy Thomerson wrote:
> On Tue, Jan 25, 2011 at 11:14 AM, Matthias Keller wrote
>> Hi List
>>
>> We've got the following scenario:
>> After a user hopped through a wizard, he'll reach a confirmation page in
>> our workflow. Now the session still needs to remain active but I want to
>> prohibit going back into the wizard and resend it again.
>> I experimented with  Session.clear()  and  Session.getPageMaps() and
>> calling pageMap.remove() on each instance returned, to no avail - after
>> clicking back, the user may still access the wizard again.
>>
>> What's the correct way to 'expire' *all* previous pages so that going back
>> using the back-button is not possible anymore? And, where do I need to put
>> that specific code (at the end of the wizard after calling
>> setResponsePage(), in the onInitialize() of the confirmation page, ... ?
>>
>   Have you looked at IPageMap#clear()?  I'm not 100% sure where you are able
> to put it.  I think you could put it just before calling setResponsePage.
>   Not after, though (since setResponsePage throws an exception that stops
> processing, your code wouldn't get called after it.)
Session.clear() does just this, it visits all pagemaps and calls clear() 
on them. Though this seems to clear up some things (when I get all 
pagemaps afterwards programmatically, they're gone), I can still go back 
with the back button and reload the pages as often as I like.
BTW, setResponsePage() does not throw any exceptions (at least not for 
1.4.X), it just stores the nexxt page somewhere in the RequestCycle for 
later usage.

It would be great if someone with deeper pagemaps-knowledge could chime 
in to find out the right place and way to clear all old pages...

> Is there some cool debugging feature or call I'd could do to see all the
>> pages in the pagemaps with their versions et al in order to find out what to
>> call to clear that...
> Add a dependency to wicket-devutils and then in your base page (hopefully
> you have a base page for all your pages), add a DebugBar.  That will have
> some links to the inspector, etc...
Thanks, I'll give it a shot this afternoon

Matt


Re: How to remove all previous pages from pagemap

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Tue, Jan 25, 2011 at 11:14 AM, Matthias Keller
<ma...@ergon.ch>wrote:

> Hi List
>
> We've got the following scenario:
> After a user hopped through a wizard, he'll reach a confirmation page in
> our workflow. Now the session still needs to remain active but I want to
> prohibit going back into the wizard and resend it again.
> I experimented with  Session.clear()  and  Session.getPageMaps() and
> calling pageMap.remove() on each instance returned, to no avail - after
> clicking back, the user may still access the wizard again.
>
> What's the correct way to 'expire' *all* previous pages so that going back
> using the back-button is not possible anymore? And, where do I need to put
> that specific code (at the end of the wizard after calling
> setResponsePage(), in the onInitialize() of the confirmation page, ... ?
>

 Have you looked at IPageMap#clear()?  I'm not 100% sure where you are able
to put it.  I think you could put it just before calling setResponsePage.
 Not after, though (since setResponsePage throws an exception that stops
processing, your code wouldn't get called after it.)

Is there some cool debugging feature or call I'd could do to see all the
> pages in the pagemaps with their versions et al in order to find out what to
> call to clear that...?
>

Add a dependency to wicket-devutils and then in your base page (hopefully
you have a base page for all your pages), add a DebugBar.  That will have
some links to the inspector, etc...
-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*