Re: Correct way to get current page instance

2016-02-11 Thread Rakesh A
Clear 

Thank you,
Rakesh.A

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Correct-way-to-get-current-page-instance-tp4673548p4673550.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Correct way to get current page instance

2016-02-10 Thread Martin Grigorov
Hi,

Both are correct but the second way is the simpler one.
PageRequestHandlerTracker's purpose is to give you the instance for the
requested page (#getFirstHandler()) and the last/response page.
E.g. if you are at PageA and you click a link that does
setResponsePage(PageB) then first=PageA and last=PageB.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Feb 11, 2016 at 7:58 AM, Rakesh A 
wrote:

> Hi,
> I see two possibilities to access current page instance using
> "PageRequestHandlerTracker"
> One
>
> IRequestHandler requestHandler =
> RequestCycle.get().getActiveRequestHandler();
> if (requestHandler instanceof IRequestHandlerDelegate)
> {
>   requestHandler = ((IRequestHandlerDelegate)
> requestHandler).getDelegateHandler();
> }
>
> if (requestHandler instanceof IPageRequestHandler)
> {
>   IPageRequestHandler pageRequestHandler = (IPageRequestHandler)
> requestHandler;
>   if (pageRequestHandler.isPageInstanceCreated())
>   {
> IRequestablePage page = pageRequestHandler.getPage();
>   }
> }
>
> Two
>PageRequestHandlerTracker.getLastHandler(RequestCycle.get()).getPage();
>
> Option#2 looks simpler, but
> Is there any difference between the two?
> What is correct way to get current page instance?
>
> Regards,
> Rakesh.A
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Correct-way-to-get-current-page-instance-tp4673548.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Correct way to get current page instance

2016-02-10 Thread Rakesh A
Hi,
I see two possibilities to access current page instance using
"PageRequestHandlerTracker"
One

IRequestHandler requestHandler =
RequestCycle.get().getActiveRequestHandler();
if (requestHandler instanceof IRequestHandlerDelegate)
{
  requestHandler = ((IRequestHandlerDelegate)
requestHandler).getDelegateHandler();
}

if (requestHandler instanceof IPageRequestHandler)
{
  IPageRequestHandler pageRequestHandler = (IPageRequestHandler)
requestHandler;
  if (pageRequestHandler.isPageInstanceCreated())
  {
IRequestablePage page = pageRequestHandler.getPage();
  }
}

Two
   PageRequestHandlerTracker.getLastHandler(RequestCycle.get()).getPage();

Option#2 looks simpler, but
Is there any difference between the two?
What is correct way to get current page instance?

Regards,
Rakesh.A

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Correct-way-to-get-current-page-instance-tp4673548.html
Sent from the Users forum mailing list archive at Nabble.com.

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