org.apache.wicket.request
Class UrlRenderer

java.lang.Object
  extended by org.apache.wicket.request.UrlRenderer

public class UrlRenderer
extends java.lang.Object

Takes care of rendering URLs.

Normally Urls are rendered relative to the base Url. Base Url is normally Url of the page being rendered. However, during Ajax request and redirect to buffer rendering the BaseUrl needs to be adjusted.

Author:
Matej Knopp, Igor Vaynberg

Constructor Summary
UrlRenderer(Request request)
          Construct.
 
Method Summary
 Url getBaseUrl()
          Returns the base Url.
 java.lang.String renderContextPathRelativeUrl(java.lang.String url)
          Deprecated.  
 java.lang.String renderContextRelativeUrl(java.lang.String url)
          Renders the URL within context relative to current base URL.
 java.lang.String renderFullUrl(Url url)
          Renders a full URL in the protocol://hostname:port/path format
 java.lang.String renderRelativeUrl(Url url)
          Renders the Url relative to currently set Base Url.
 java.lang.String renderUrl(Url url)
          Renders the Url
protected  java.lang.String resolveHost(Url url)
          Gets the host name that should be used to render the url
protected  java.lang.Integer resolvePort(Url url)
          Gets port that should be used to render the url
protected  java.lang.String resolveProtocol(Url url)
          Gets the protocol that should be used to render the url
 Url setBaseUrl(Url base)
          Sets the base Url.
protected  boolean shouldRenderAsFull(Url url)
          Determines whether a URL should be rendered in its full form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlRenderer

public UrlRenderer(Request request)
Construct.

Parameters:
request - Request that serves as the base for rendering urls
Method Detail

setBaseUrl

public Url setBaseUrl(Url base)
Sets the base Url. All generated URLs will be relative to this Url.

Parameters:
base -
Returns:
original base Url

getBaseUrl

public Url getBaseUrl()
Returns the base Url.

Returns:
base Url

renderUrl

public java.lang.String renderUrl(Url url)
Renders the Url

Parameters:
url -
Returns:
Url rendered as string

renderFullUrl

public java.lang.String renderFullUrl(Url url)
Renders a full URL in the protocol://hostname:port/path format

Parameters:
url -
Returns:
rendered URL

resolvePort

protected java.lang.Integer resolvePort(Url url)
Gets port that should be used to render the url

Parameters:
url - url being rendered
Returns:
port or null if none is set

resolveHost

protected java.lang.String resolveHost(Url url)
Gets the host name that should be used to render the url

Parameters:
url - url being rendered
Returns:
the host name or null if none is set

resolveProtocol

protected java.lang.String resolveProtocol(Url url)
Gets the protocol that should be used to render the url

Parameters:
url - url being rendered
Returns:
the protocol or null if none is set

renderRelativeUrl

public java.lang.String renderRelativeUrl(Url url)
Renders the Url relative to currently set Base Url. This method is only intended for Wicket URLs, because the Url object represents part of URL after Wicket Filter. For general URLs within context use renderContextPathRelativeUrl(String)

Parameters:
url -
Returns:
Url rendered as string

shouldRenderAsFull

protected boolean shouldRenderAsFull(Url url)
Determines whether a URL should be rendered in its full form

Parameters:
url -
Returns:
true if URL should be rendered in the full form

renderContextRelativeUrl

public java.lang.String renderContextRelativeUrl(java.lang.String url)
Renders the URL within context relative to current base URL.

Parameters:
url -
Returns:
relative URL

renderContextPathRelativeUrl

@Deprecated
public java.lang.String renderContextPathRelativeUrl(java.lang.String url)
Deprecated. 

Renders the URL within context relative to current base URL.

Parameters:
url -
Returns:
relative URL
See Also:
renderContextRelativeUrl(String)


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.