You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alfonso Quiroga <al...@gmail.com> on 2012/11/16 15:33:38 UTC

retriving the actual page instance

Hi, is there a way to get the actual IRequestablePage? I have only one, and
if I debug the HttpSession, I have this key:
"wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which holds
the PageStoreManager$SessionEntry, where is the actual page I'm looking for.

I don't want to access in that way (navigating throw the raw httpSession).
I think there should be a better way using Wicket classes. Does anybody
know? thanks!

Re: retriving the actual page instance

Posted by Alfonso Quiroga <al...@gmail.com>.
Thanks to both. Alec approach worked for me in other case, not in this one.

In this case, we had the problem that StaleException was rising, when user
open multiple tabs with the same session (like Firefox)
In that case, I was invalidating the whole session and redirecting to
login. But now, the user stays in the same page (with the last state) using
Session.get().getPageManager().getPage( id )

So now, the user can have multiple tabs and works fine. Thanks to both
Martin and Alec!


On Fri, Nov 16, 2012 at 1:30 PM, Alec Swan <al...@gmail.com> wrote:

> I used this approach
> https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html to
> retrieve the last page instance from request cycle.
>
> 1. Register handler in your Application:
> getRequestCycleListeners().add(new PageRequestHandlerTracker());
> 2. Retrieve page as follows:
> IPageRequestHandler lastHandler =
> PageRequestHandlerTracker.getLastHandler(RequestCycle.get());
> IRequestablePage page = lastHandler == null ? null : lastHandler.getPage();
>
> Hope this helps,
>
> Alec
>
> On Fri, Nov 16, 2012 at 8:55 AM, Martin Grigorov <mg...@apache.org>
> wrote:
> > Why do you need this functionality ?
> >
> >
> > On Fri, Nov 16, 2012 at 5:54 PM, Alfonso Quiroga <alfonsosebaq@gmail.com
> >wrote:
> >
> >> Martin, thank you again!
> >> This helps me a lot! what I dislike is that I need to know the page id,
> is
> >> there a way to know the "last" page id? by now.. I'll put this id in the
> >> session
> >>
> >>
> >> On Fri, Nov 16, 2012 at 11:47 AM, Martin Grigorov <mgrigorov@apache.org
> >> >wrote:
> >>
> >> > Hi,
> >> >
> >> > The official way is: session.getPageManager().getPage(pageId)
> >> > This will look in the httpsession and fallback to disk.
> >> >
> >> >
> >> > On Fri, Nov 16, 2012 at 4:33 PM, Alfonso Quiroga <
> alfonsosebaq@gmail.com
> >> > >wrote:
> >> >
> >> > > Hi, is there a way to get the actual IRequestablePage? I have only
> one,
> >> > and
> >> > > if I debug the HttpSession, I have this key:
> >> > > "wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which
> >> holds
> >> > > the PageStoreManager$SessionEntry, where is the actual page I'm
> looking
> >> > > for.
> >> > >
> >> > > I don't want to access in that way (navigating throw the raw
> >> > httpSession).
> >> > > I think there should be a better way using Wicket classes. Does
> anybody
> >> > > know? thanks!
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > Martin Grigorov
> >> > jWeekend
> >> > Training, Consulting, Development
> >> > http://jWeekend.com <http://jweekend.com/>
> >> >
> >>
> >
> >
> >
> > --
> > Martin Grigorov
> > jWeekend
> > Training, Consulting, Development
> > http://jWeekend.com <http://jweekend.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: retriving the actual page instance

Posted by Alec Swan <al...@gmail.com>.
I used this approach
https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html to
retrieve the last page instance from request cycle.

1. Register handler in your Application:
getRequestCycleListeners().add(new PageRequestHandlerTracker());
2. Retrieve page as follows:
IPageRequestHandler lastHandler =
PageRequestHandlerTracker.getLastHandler(RequestCycle.get());
IRequestablePage page = lastHandler == null ? null : lastHandler.getPage();

Hope this helps,

Alec

On Fri, Nov 16, 2012 at 8:55 AM, Martin Grigorov <mg...@apache.org> wrote:
> Why do you need this functionality ?
>
>
> On Fri, Nov 16, 2012 at 5:54 PM, Alfonso Quiroga <al...@gmail.com>wrote:
>
>> Martin, thank you again!
>> This helps me a lot! what I dislike is that I need to know the page id, is
>> there a way to know the "last" page id? by now.. I'll put this id in the
>> session
>>
>>
>> On Fri, Nov 16, 2012 at 11:47 AM, Martin Grigorov <mgrigorov@apache.org
>> >wrote:
>>
>> > Hi,
>> >
>> > The official way is: session.getPageManager().getPage(pageId)
>> > This will look in the httpsession and fallback to disk.
>> >
>> >
>> > On Fri, Nov 16, 2012 at 4:33 PM, Alfonso Quiroga <alfonsosebaq@gmail.com
>> > >wrote:
>> >
>> > > Hi, is there a way to get the actual IRequestablePage? I have only one,
>> > and
>> > > if I debug the HttpSession, I have this key:
>> > > "wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which
>> holds
>> > > the PageStoreManager$SessionEntry, where is the actual page I'm looking
>> > > for.
>> > >
>> > > I don't want to access in that way (navigating throw the raw
>> > httpSession).
>> > > I think there should be a better way using Wicket classes. Does anybody
>> > > know? thanks!
>> > >
>> >
>> >
>> >
>> > --
>> > Martin Grigorov
>> > jWeekend
>> > Training, Consulting, Development
>> > http://jWeekend.com <http://jweekend.com/>
>> >
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>

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


Re: retriving the actual page instance

Posted by Martin Grigorov <mg...@apache.org>.
Why do you need this functionality ?


On Fri, Nov 16, 2012 at 5:54 PM, Alfonso Quiroga <al...@gmail.com>wrote:

> Martin, thank you again!
> This helps me a lot! what I dislike is that I need to know the page id, is
> there a way to know the "last" page id? by now.. I'll put this id in the
> session
>
>
> On Fri, Nov 16, 2012 at 11:47 AM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
>
> > Hi,
> >
> > The official way is: session.getPageManager().getPage(pageId)
> > This will look in the httpsession and fallback to disk.
> >
> >
> > On Fri, Nov 16, 2012 at 4:33 PM, Alfonso Quiroga <alfonsosebaq@gmail.com
> > >wrote:
> >
> > > Hi, is there a way to get the actual IRequestablePage? I have only one,
> > and
> > > if I debug the HttpSession, I have this key:
> > > "wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which
> holds
> > > the PageStoreManager$SessionEntry, where is the actual page I'm looking
> > > for.
> > >
> > > I don't want to access in that way (navigating throw the raw
> > httpSession).
> > > I think there should be a better way using Wicket classes. Does anybody
> > > know? thanks!
> > >
> >
> >
> >
> > --
> > Martin Grigorov
> > jWeekend
> > Training, Consulting, Development
> > http://jWeekend.com <http://jweekend.com/>
> >
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: retriving the actual page instance

Posted by Alfonso Quiroga <al...@gmail.com>.
Martin, thank you again!
This helps me a lot! what I dislike is that I need to know the page id, is
there a way to know the "last" page id? by now.. I'll put this id in the
session


On Fri, Nov 16, 2012 at 11:47 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> The official way is: session.getPageManager().getPage(pageId)
> This will look in the httpsession and fallback to disk.
>
>
> On Fri, Nov 16, 2012 at 4:33 PM, Alfonso Quiroga <alfonsosebaq@gmail.com
> >wrote:
>
> > Hi, is there a way to get the actual IRequestablePage? I have only one,
> and
> > if I debug the HttpSession, I have this key:
> > "wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which holds
> > the PageStoreManager$SessionEntry, where is the actual page I'm looking
> > for.
> >
> > I don't want to access in that way (navigating throw the raw
> httpSession).
> > I think there should be a better way using Wicket classes. Does anybody
> > know? thanks!
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>

Re: retriving the actual page instance

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

The official way is: session.getPageManager().getPage(pageId)
This will look in the httpsession and fallback to disk.


On Fri, Nov 16, 2012 at 4:33 PM, Alfonso Quiroga <al...@gmail.com>wrote:

> Hi, is there a way to get the actual IRequestablePage? I have only one, and
> if I debug the HttpSession, I have this key:
> "wicket:wicket.wicketGuide:wicket:persistentPageManagerData" which holds
> the PageStoreManager$SessionEntry, where is the actual page I'm looking
> for.
>
> I don't want to access in that way (navigating throw the raw httpSession).
> I think there should be a better way using Wicket classes. Does anybody
> know? thanks!
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>