wicket.protocol.http.request
Class WebRequestCodingStrategy

java.lang.Object
  extended by wicket.protocol.http.request.WebRequestCodingStrategy
All Implemented Interfaces:
IRequestCodingStrategy, IRequestTargetMounter, IRequestTargetMountsInfo
Direct Known Subclasses:
WebURLCompressingCodingStrategy

public class WebRequestCodingStrategy
extends java.lang.Object
implements IRequestCodingStrategy, IRequestTargetMountsInfo

Request parameters factory implementation that uses http request parameters and path info to construct the request parameters object.

Author:
Eelco Hillenius, Jonathan Locke

Field Summary
static java.lang.String BEHAVIOR_ID_PARAMETER_NAME
          AJAX query parameter name
static java.lang.String BOOKMARKABLE_PAGE_PARAMETER_NAME
          Parameter name used all over the place
static java.lang.String IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME
          Parameter name that tells decode to ignore this request if the page+version encoded in the url is not on top of the stack.
static java.lang.String INTERFACE_PARAMETER_NAME
          Name of interface target query parameter
static java.lang.String NAME_SPACE
          Name of interface target query parameter
static java.lang.String PAGEMAP
          Pagemap parameter constant
 
Constructor Summary
WebRequestCodingStrategy()
          Construct.
 
Method Summary
protected  void addBookmarkablePageParameters(Request request, RequestParameters parameters)
          Adds bookmarkable page related parameters (page alias and optionally page parameters).
protected  void addInterfaceParameters(Request request, RequestParameters parameters)
          Adds page related parameters (path and pagemap and optionally version and interface).
protected  void addResourceParameters(Request request, RequestParameters parameters)
          Adds (shared) resource related parameters (resource key).
 RequestParameters decode(Request request)
          Analyze the request and create a corresponding request parameters object for it.
protected  java.lang.String doEncode(RequestCycle requestCycle, IRequestTarget requestTarget)
          In case you are using custom targets that are not part of the default target hierarchy, you need to override this method, which will be called after the defaults have been tried.
protected  java.lang.CharSequence encode(RequestCycle requestCycle, IBookmarkablePageRequestTarget requestTarget)
          Encode a page class target.
protected  java.lang.CharSequence encode(RequestCycle requestCycle, IListenerInterfaceRequestTarget requestTarget)
          Encode a listener interface target.
protected  java.lang.CharSequence encode(RequestCycle requestCycle, IPageRequestTarget requestTarget)
          Encode a page target.
 java.lang.CharSequence encode(RequestCycle requestCycle, IRequestTarget requestTarget)
          Encode the given request target.
protected  java.lang.CharSequence encode(RequestCycle requestCycle, ISharedResourceRequestTarget requestTarget)
          Encode a shared resource target.
protected  IRequestTargetUrlCodingStrategy getMountEncoder(IRequestTarget requestTarget)
          Gets the mount encoder for the given request target if any.
protected  java.lang.String getRequestPath(Request request)
          Gets the request info path.
 IRequestTargetUrlCodingStrategy[] listMounts()
          List the mounts that are known to the implementing mounter.
 void mount(java.lang.String path, IRequestTargetUrlCodingStrategy encoder)
          Mounts a request target with the given path.
 java.lang.CharSequence pathForTarget(IRequestTarget requestTarget)
          Gets the url that the provided request target conforms to.
 IRequestTarget targetForRequest(RequestParameters requestParameters)
          Gets the request target that conforms to the given request parameters.
 void unmount(java.lang.String path)
          Unmounts a request target.
 IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(java.lang.String path)
          Gets the encoder that was mounted on the provided path if any.
protected  java.lang.CharSequence urlPrefix(RequestCycle requestCycle)
          Gets prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_SPACE

public static final java.lang.String NAME_SPACE
Name of interface target query parameter

See Also:
Constant Field Values

INTERFACE_PARAMETER_NAME

public static final java.lang.String INTERFACE_PARAMETER_NAME
Name of interface target query parameter

See Also:
Constant Field Values

BEHAVIOR_ID_PARAMETER_NAME

public static final java.lang.String BEHAVIOR_ID_PARAMETER_NAME
AJAX query parameter name

See Also:
Constant Field Values

BOOKMARKABLE_PAGE_PARAMETER_NAME

public static final java.lang.String BOOKMARKABLE_PAGE_PARAMETER_NAME
Parameter name used all over the place

See Also:
Constant Field Values

PAGEMAP

public static final java.lang.String PAGEMAP
Pagemap parameter constant

See Also:
Constant Field Values

IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME

public static final java.lang.String IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME
Parameter name that tells decode to ignore this request if the page+version encoded in the url is not on top of the stack. The value of this parameter is not important, it simply has to be present to enable the behavior

See Also:
Constant Field Values
Constructor Detail

WebRequestCodingStrategy

public WebRequestCodingStrategy()
Construct.

Method Detail

decode

public final RequestParameters decode(Request request)
Description copied from interface: IRequestCodingStrategy
Analyze the request and create a corresponding request parameters object for it.

Specified by:
decode in interface IRequestCodingStrategy
Parameters:
request - the incoming request
Returns:
a request parameters object that corresponds to the request
See Also:
IRequestCodingStrategy.decode(wicket.Request)

encode

public final java.lang.CharSequence encode(RequestCycle requestCycle,
                                           IRequestTarget requestTarget)
Encode the given request target. If a mount is found, that mounted url will be returned. Otherwise, one of the delegation methods will be called. In case you are using custom targets that are not part of the default target hierarchy, you need to override doEncode(RequestCycle, IRequestTarget), which will be called after the defaults have been tried. When that doesn't provide a url either, and exception will be thrown saying that encoding could not be done.

Specified by:
encode in interface IRequestCodingStrategy
Parameters:
requestCycle - the current request cycle (for efficient access)
requestTarget - the request target
Returns:
the url to the provided target
See Also:
IRequestCodingStrategy.encode(wicket.RequestCycle, wicket.IRequestTarget)

listMounts

public IRequestTargetUrlCodingStrategy[] listMounts()
Description copied from interface: IRequestTargetMountsInfo
List the mounts that are known to the implementing mounter.

Specified by:
listMounts in interface IRequestTargetMountsInfo
Returns:
the mounts that are known to the implementing mounter
See Also:
IRequestTargetMountsInfo.listMounts()

urlCodingStrategyForPath

public final IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(java.lang.String path)
Description copied from interface: IRequestTargetMounter
Gets the encoder that was mounted on the provided path if any.

Specified by:
urlCodingStrategyForPath in interface IRequestTargetMounter
Parameters:
path - the path
Returns:
The encoder/decoder that was mounted on the provided path, if any
See Also:
IRequestTargetMounter.urlCodingStrategyForPath(java.lang.String)

mount

public final void mount(java.lang.String path,
                        IRequestTargetUrlCodingStrategy encoder)
Description copied from interface: IRequestTargetMounter
Mounts a request target with the given path.

Specified by:
mount in interface IRequestTargetMounter
Parameters:
path - the path to mount the request target with
encoder - The strategy to use for encoding and decoding urls
See Also:
IRequestTargetMounter.mount(java.lang.String, wicket.request.target.coding.IRequestTargetUrlCodingStrategy)

pathForTarget

public final java.lang.CharSequence pathForTarget(IRequestTarget requestTarget)
Description copied from interface: IRequestTargetMounter
Gets the url that the provided request target conforms to.

Specified by:
pathForTarget in interface IRequestTargetMounter
Parameters:
requestTarget - the request target
Returns:
The url that the provided request target conforms to
See Also:
IRequestTargetMounter.pathForTarget(wicket.IRequestTarget)

targetForRequest

public final IRequestTarget targetForRequest(RequestParameters requestParameters)
Description copied from interface: IRequestTargetMounter
Gets the request target that conforms to the given request parameters.

Specified by:
targetForRequest in interface IRequestTargetMounter
Parameters:
requestParameters - the request parameters
Returns:
the request target or null if nothing was mounted with the given request parameters
See Also:
IRequestTargetMounter.targetForRequest(wicket.request.RequestParameters)

unmount

public final void unmount(java.lang.String path)
Description copied from interface: IRequestTargetMounter
Unmounts a request target.

Specified by:
unmount in interface IRequestTargetMounter
Parameters:
path - the path to unmount
See Also:
IRequestTargetMounter.unmount(java.lang.String)

addBookmarkablePageParameters

protected void addBookmarkablePageParameters(Request request,
                                             RequestParameters parameters)
Adds bookmarkable page related parameters (page alias and optionally page parameters). Any bookmarkable page alias mount will override this method; hence if a mount is found, this method will not be called. If you override this method to behave different then also encode(RequestCycle, IBookmarkablePageRequestTarget) should be overridden to by in sync with that behaviour.

Parameters:
request - the incoming request
parameters - the parameters object to set the found values on

addInterfaceParameters

protected void addInterfaceParameters(Request request,
                                      RequestParameters parameters)
Adds page related parameters (path and pagemap and optionally version and interface). If you override this method to behave different then also encode(RequestCycle, IListenerInterfaceRequestTarget) should be overridden to by in sync with that behaviour.

Parameters:
request - the incoming request
parameters - the parameters object to set the found values on

addResourceParameters

protected void addResourceParameters(Request request,
                                     RequestParameters parameters)
Adds (shared) resource related parameters (resource key). Any shared resource key mount will override this method; hence if a mount is found, this method will not be called. If you override this method to behave different then also encode(RequestCycle, ISharedResourceRequestTarget) should be overridden to by in sync with that behaviour.

Parameters:
request - the incomming request
parameters - the parameters object to set the found values on

doEncode

protected java.lang.String doEncode(RequestCycle requestCycle,
                                    IRequestTarget requestTarget)
In case you are using custom targets that are not part of the default target hierarchy, you need to override this method, which will be called after the defaults have been tried. When this doesn't provide a url either (returns null), an exception will be thrown by the encode method saying that encoding could not be done.

Parameters:
requestCycle - the current request cycle (for efficient access)
requestTarget - the request target
Returns:
the url to the provided target

encode

protected java.lang.CharSequence encode(RequestCycle requestCycle,
                                        IBookmarkablePageRequestTarget requestTarget)
Encode a page class target. If you override this method to behave different then also addBookmarkablePageParameters(Request, RequestParameters) should be overridden to by in sync with that behaviour.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(RequestCycle requestCycle,
                                        ISharedResourceRequestTarget requestTarget)
Encode a shared resource target. If you override this method to behave different then also addResourceParameters(Request, RequestParameters) should be overridden to by in sync with that behaviour.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(RequestCycle requestCycle,
                                        IListenerInterfaceRequestTarget requestTarget)
Encode a listener interface target. If you override this method to behave different then also addInterfaceParameters(Request, RequestParameters) should be overridden to by in sync with that behaviour.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

encode

protected java.lang.CharSequence encode(RequestCycle requestCycle,
                                        IPageRequestTarget requestTarget)
Encode a page target.

Parameters:
requestCycle - the current request cycle
requestTarget - the target to encode
Returns:
the encoded url

getMountEncoder

protected IRequestTargetUrlCodingStrategy getMountEncoder(IRequestTarget requestTarget)
Gets the mount encoder for the given request target if any.

Parameters:
requestTarget - the request target to match
Returns:
the mount encoder if any

getRequestPath

protected java.lang.String getRequestPath(Request request)
Gets the request info path. This is an overridable method in order to provide users with a means to implement e.g. a path encryption scheme. This method by default returns Request.getPath().

Parameters:
request - the request
Returns:
the path info object, possibly processed

urlPrefix

protected final java.lang.CharSequence urlPrefix(RequestCycle requestCycle)
Gets prefix.

Parameters:
requestCycle - the request cycle
Returns:
prefix


Copyright © 2004-2007 Wicket developers. All Rights Reserved.