The web designer gave me HTML that looks like this:
<div .... style="background: transparent url(xxx.png) 170px center no-repeat">
Unfortunately, the content of the xxx.png image xxx.png generated by the software, so I made it a WebResource and used the following strategy to create a resource URL, which I then embed in the style= attribute using the AttributeModifier Wicket.
// App initialization code String resourceName = ....; getSharedResources().add(resourceName, myWebResource); // Creating the widget String url = getServletContext().getContextPath() + "/resources/org.apache.wicket.Application/" + resourceName ; String style = "background: transparent url(" + url + ") 170px center no-repeat"; div.add(new AttributeModifier("style", new Model<String>(style)));
This works fine when I test it locally with Eclipse, but:
- When I install this during production, I want Apache to be a Jetty proxy so that the context root is not displayed, i.e. Apache sends a
/foo request to Jetty as /context-root/foo . - All in all, I donβt think it is very elegant. Am I sure I duplicate Wicket code here?
I understand that Wicket solves this issue of Apache's contextual roots and proxy using only relative URLs. That would be the most elegant solution I suspect. But if I have, for example, a IndexedParamUrlCodingStrategy , then the URL can be of arbitrary length, and I do not know how much .. to include in order to return to /resources .
Change The current solution is to use absolute URLs, as in my code example above, and in Apache (a) rewrite /context-root/* in /* (b), as before, then ADD the root context for all requests (c) forward jetty. Thus, most URLs can be without a root context, but some URLs (to my resources) can have a root context and this is normal. But I do not like it!
wicket
Adrian smith
source share