See inline.

On 06/06/2013 5:27 PM, bronius wrote:
First of all Url api is extremely hard to work with, very hard to create url
i need, I think there should be some option to simply create it with simple
string. Anyway Url.parse method does not create full url for me (i have
localhost:8080/site1 and localhost:8080/site2, but when url is created i get
only site2 without full address). So I tried it myself like this:
  private Url createUrl(Charset charset) {
         Url url = new Url(charset) {
             private static final long serialVersionUID = 1L;
             public String toString(final Charset charset)
                 return toString(StringMode.FULL, charset);
         url.setQueryParameter("param1", "1");
         url.setQueryParameter("param2", "2");
         return url;
The key here as you probably noticed is StringMode.FULL passed to the toString method. The Url class stores separately the protocol, host name, port and path (the segments array) of a Url.

Either way, toString is only used to build a resource key name in the constructor of UrlResourceReference. The actual url is still used in full by UrlResourceReference. However, see below.

Not really nice, but at least Url object returned normal full url that i
needed in toString. However UrlResourceReference still rendered not full url
and thats where i got too pissed off and decided I need some rest :) I'm
just interested if I'm even on the right track? How you would implement it?
And why this simple thing is so complicated? :) I admit I was a bit drunk :)
and don't have that much of experience with wicket, but this part looked
really strange for me. But I suspect I'm missing something. The problem is
probably because both applications have same start (http://localhost:8080)
and wicket is too smart. As image from other random website is shown
You are right. In a way, Wicket is "too smart". Here is the code of interest from org.apache.wicket.request.UrlRenderer:
    protected boolean shouldRenderAsFull(final Url url)
        Url clientUrl = request.getClientUrl();

        if (!Strings.isEmpty(url.getProtocol()) &&
            return true;
if (!Strings.isEmpty(url.getHost()) && !url.getHost().equals(clientUrl.getHost()))
            return true;
if ((url.getPort() != null) && !url.getPort().equals(clientUrl.getPort()))
            return true;
        if (url.isContextAbsolute())
            // do not relativize urls like "/a/b"
            return true;
        return false;

What I don't understand however is why this relative url is not good for you. You talked about serving resources from another server, but I don't get it. Either a relative url or an absolute url would both point to the same resource when interpreted on the client.


To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to