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 <[email protected]> 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: [email protected] > For additional commands, e-mail: [email protected] > >
