tags:

views:

15

answers:

0

Bear with me, this is a bit of an in-depth problem.

I'm having some problems correctly addressing URLs in wicket when mounts are deployed. In my development environment, the application root is something like http://localhost:8080/development/app

I then have a database of mounts which the client can setup, these are applied at application start, and updated whenever any changes to the mount database is made (this works surprisingly well). This database also contains page parameters which are loaded based on the request url if no parameters are passed in the URL.

However we encountered a problem, when a page is mounted, wicket will decode the url from the class parameter to the last mounted url, this became a problem when I mounted Article under /about and /map/london. We fixed this by adding a second class; ArticleProxy, which essentially extends Article, this way we can mount Article as /article and only reference that through Wicket links while ArticleProxy we can mount several times and only reference through HTML.

We then added a navigation structure, and one of the navigation link types was previously-mounted-page, so essentially a drop-down of our mounts. This is where it got tricky, to get the raw urls to work we needed to use ExternalLink and RequestUtil to get the correct URLs for the context-root-relative paths that the mounts use.

This worked fine until we encountered mounts with apparent-sub-folders like /map/london, this is a single mount and works fine in wicket, but when we are viewing /map/london, RequestUtils.toAbsolutePath encodes /about to http://localhost:8080/development/app/map/about rather than the expected http://localhost:8080/development/app/about.

In short: Is there a better way to derive the correct context root, or am I forced to add it to a config parameter, something which I really don't want to do. RequestUtils does a lousy job.