Wicket 1.5 and getting the url for the page instance

What do I need to fix in Wicket 1.5 to get the URL of the page instance?

In Wicket 1.4.x, this worked:

MyPage page = new MyPage(some, parameters); getRequestCycle().urlFor(page).toString() 

A bunch of different versions of urlFor() was removed from RequestCycle in Wicket 1.5 , among which were urlFor (Page page) , which I used in Wicket 1.4.

+7
source share
3 answers

You need: org.apache.wicket.request.cycle.RequestCycle # urlFor (IRequestHandler).

 cycle.urlFor(new RenderPageRequestHandler(new PageProvider(page))) 

I am not sure why this was not carried forward. I think because it is not widely used ...

+9
source

org.apache.wicket.RequestCycle.urlFor has been renamed org.apache.wicket.request.cycle.RequestCycle.urlFor (see here )

[edit] Guilty. Try

 RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(urlFor(MyPage.class,null).toString())); 

(taken from here )

0
source

Try

 RequestUtils.toAbsolutePath(urlFor(MyPage.class, params).toString(), "/"); 

See JavaDoc of RequestUtils and Component as suplier for urlFor for (meager) details ... But the interface should be pretty self-revealing. Just set the target class and PageParams-Object and execute (basically)

-one
source

All Articles