Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicket: Relative to absolute URL or get base URL

Tags:

java

url

wicket

If I have a relative path to a static asset (flash/blah.swf), what is the best way to programmatically convert this to an absolute URL (http://localhost/app/flash/blah.swf)? Or what is the best way to get the base URL of the Wicket application? I've tried using RequestUtils.toAbsolutePath but it doesn't seem to work reliably and is frequently throwing exceptions. This needs to work on all servers the app is deployed to.

like image 881
Gilean Avatar asked Apr 12 '10 04:04

Gilean


1 Answers

For Wicket 6 it is

String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse("my-relative-url.html"));
like image 178
Manuel Manhart Avatar answered Sep 24 '22 00:09

Manuel Manhart