I'm a bit confused about ContextImage; according to the javadocs the image path "will be prefixed such that the image is relative to the context root".

In my markup I've got:
<img wicket:id="logo" src="mylogo.gif" />

Then I add the Context image to my WebPage:
add(new ContextImage("logo", "images/logos/mylogo.gif"));

... and I end up with:
<img src="../images/logos/mylogo.gif" />

My application is deployed with a context root of /myapp and this doesn't work, it will only work if the application is deployed with a context root of /. I've checked the source which ContextImage uses to get the context root and in org.apache.wicket.Request it says:

 * Gets a prefix to make this relative to the context root.
 * <p>
* For example, if your context root is http://server.com/myApp/ and the request is for
 * /myApp/mountedPage/, then the prefix returned might be "../../".
 * <p>
* For a particular technology, this might return either an absolute prefix or a relative one.
* @return Prefix relative to this request required to back up to context root.
public abstract String getRelativePathPrefixToContextRoot();

To me this just seems plain wrong, here it clearly states that the context root is "http://server.com/myApp/"; but the example prefix of "../../" relative to "/myApp/mountedPage/" does not take you to the context root of /myApp/ but to /.

This is very confusing as I've always considered the context root of a java web application to to be the path upon which it is deployed on the application server, whether that be /, /myApp or /apps/myApp and in the above case I do not end up with an image path relative to the context root. Without hard-coding the name of my context root in the image path (bad idea for portability) how can I reference static images stored in an images directory under the context root?

Should I file this as a bug or am I missing something?

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to