Hi,
I just hit another problem with UrlRenderer and full urls.
MyApp#init():
mountPage("/one/two/three", MyPage.class);
mountResource("/one/four", new MyResRef());
In a MyPage's #renderHead() I have something like:
String url = urlFor(new MyResRef(), null).toString();
Url parsedUrl = Url.parse(url);
String fullUrl =
getRequestCycle().getUrlRenderer().renderFullUrl(parsedUrl);
And 'fullUrl' is : http://localhost:8080/../four
I checked #renderFullUrl()'s source and indeed it expects proper
filter path relative url just to join it with
http://host/port/contextPath/filterPath
For now my workaround is :
String url = urlFor(new MyResRef(), null).toString();
UrlRenderer urlRenderer = getRequestCycle().getUrlRenderer();
String baseUrl = urlRenderer.getBaseUrl().toString();
URI baseUri = URI.create(baseUrl);
URI resolved = baseUri.resolve(url);
String fullUrl =
urlRenderer.renderFullUrl(Url.parse(resolved.toString()));
And this produces : http://localhost:8080/one/four as I'd like it.
The question is: Is there a bug in UrlRenderer#renderFullUrl() or this
is how it should behave ?
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com