ContextImage not generating expected path relative to context root 
-------------------------------------------------------------------

                 Key: WICKET-1889
                 URL: https://issues.apache.org/jira/browse/WICKET-1889
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4-M3
            Reporter: Gianni Bruno


According to the javadocs the image path for ContextImage "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 ContextImage to my WebPage:
add(new ContextImage("logo", "images/logos/mylogo.gif"));

... and I end up with the following in the generated markup:
<img src="../images/logos/mylogo.gif" />

My application is deployed with a context root of /myapp and this doesn't work 
as it resolves to http://mydomain.com/images/logos/mylogo.gif, when it should 
be http://mydomain.com/myapp/images/logos/mylogo.gif
As far as I can tell ContextImage will only work as described when 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();

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 / which is *not* the Context Root.

I guess this also effects any other components that make use of the same 
getRelativePathPrefixToContextRoot().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to