org.apache.wicket
Class RequestContext

java.lang.Object
  extended by org.apache.wicket.RequestContext
Direct Known Subclasses:
PortletRequestContext

public class RequestContext
extends Object

Handles url rewriting, provides access to the namespace for markup Ids and isolated session state.

This is the base strategy for encoding URLs, which is to leave them as is. This is mainly so that PortletRequestContext can implement it's portlet encoding strategies as portlets need to have special URLs encoded with portal information and portlet namespace.

For url rewriting, only three methods are needed to support creating Portlet ActionURLs, Portlet RenderURLs and Resource/Ajax URLs.

The RequestContext is somewhat comparable to the JSF ExternalContext interface which abstracts the external environment (like web or portlet) in which the application is currently running. As this is request dependent (the same application can technically be accessed even concurrently as web or portlet), in Wicket this context has been termed RequestContext.

Author:
Ate Douma
See Also:
PortletRequestContext

Constructor Summary
RequestContext()
          Construct.
 
Method Summary
 CharSequence encodeActionURL(CharSequence path)
          Encodes URL's for action URLs, typically overridden by the portlet implementation.
 String encodeMarkupId(String markupId)
          Encodes markup Ids, typically overridden by the portlet implementation.
 CharSequence encodeRenderURL(CharSequence path)
          Encodes URL's for render URLs, typically overridden by the portlet implementation.
 CharSequence encodeResourceURL(CharSequence path)
          Encodes URL's for resource targets, typically overridden by the portlet implementation.
 CharSequence encodeSharedResourceURL(CharSequence path)
          Encodes URL's for shared resource targets, typically overridden by the portlet implementation.
static RequestContext get()
           
 IHeaderResponse getHeaderResponse()
          Used to override response objects, typically used by the portlet implementation.
 CharSequence getNamespace()
           
 boolean isPortletRequest()
           
protected static void set(RequestContext context)
          Sets the RequestContext for the current threads active request.
static void unset()
          Resets the RequestContext for the current threads active request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestContext

public RequestContext()
Construct.

Method Detail

get

public static final RequestContext get()
Returns:
The current threads request context, will make one if there wasn't one.

unset

public static final void unset()
Resets the RequestContext for the current threads active request.


set

protected static final void set(RequestContext context)
Sets the RequestContext for the current threads active request.

Parameters:
context -

getNamespace

public CharSequence getNamespace()
Returns:
CharSequence the namespace of this request, typically overridden by the portlet implementation.
See Also:
PortletRequestContext.getNamespace()

encodeMarkupId

public String encodeMarkupId(String markupId)
Encodes markup Ids, typically overridden by the portlet implementation.

Parameters:
markupId - the markup Id to encode
Returns:
the encoded markup
See Also:
PortletRequestContext.encodeMarkupId(String)

encodeActionURL

public CharSequence encodeActionURL(CharSequence path)
Encodes URL's for action URLs, typically overridden by the portlet implementation.

Parameters:
path - the URL to encode
Returns:
the encoded url
See Also:
PortletRequestContext.encodeActionURL(CharSequence)

encodeRenderURL

public CharSequence encodeRenderURL(CharSequence path)
Encodes URL's for render URLs, typically overridden by the portlet implementation.

Parameters:
path - the URL to encode
Returns:
the encoded url
See Also:
PortletRequestContext.encodeRenderURL(CharSequence)

encodeResourceURL

public CharSequence encodeResourceURL(CharSequence path)
Encodes URL's for resource targets, typically overridden by the portlet implementation.

Parameters:
path - the URL to encode
Returns:
the encoded url
See Also:
PortletRequestContext.encodeResourceURL(CharSequence)

encodeSharedResourceURL

public CharSequence encodeSharedResourceURL(CharSequence path)
Encodes URL's for shared resource targets, typically overridden by the portlet implementation.

Parameters:
path - the URL to encode
Returns:
the encoded url
See Also:
ISharedResourceRequestTarget, PortletRequestContext.encodeSharedResourceURL(CharSequence)

getHeaderResponse

public IHeaderResponse getHeaderResponse()
Used to override response objects, typically used by the portlet implementation.

In a Portlet environment, this allows the portlet container/portal to capture the HeaderResponse as a separate stream for merging in the overall page header (together with header output for other portlets).

Returns:
The IHeaderResponse
See Also:
PortletRequestContext.getHeaderResponse()

isPortletRequest

public boolean isPortletRequest()
Returns:
boolean true if this is a portlet request


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