org.apache.wicket.request.target.coding
Class QueryStringUrlCodingStrategy

java.lang.Object
  extended by org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy
      extended by org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy
          extended by org.apache.wicket.request.target.coding.QueryStringUrlCodingStrategy
All Implemented Interfaces:
IMountableRequestTargetUrlCodingStrategy, IRequestTargetUrlCodingStrategy

public class QueryStringUrlCodingStrategy
extends BookmarkablePageRequestTargetUrlCodingStrategy

Encodes and decodes mounts for a single bookmarkable page class, but with the parameters appended in a URL query string rather than integrated into a URL hierarchical path.

For example, whereas BookmarkablePageRequestTargetUrlCodingStrategy might encode a request target as "mywebapp/myservlet/admin/productmanagement/action/edit/product/4995", QueryStringRequestTargetUrlCodingStrategy would encode the same target as "mywebapp/myservlet/admin/productmanagement?action=edit&product=4995".

URLs encoded in this way can be bookmarked just as easily as those produced by BookmarkablePageRequestTargetUrlCodingStrategy. For example, Google searches produce bookmarkable links with query strings.

Whether BookmarkablePageRequestTargetUrlCodingStrategy or QueryStringRequestTargetUrlCodingStrategy is appropriate for a given mount depends on:

Regardless of which coding strategy is chosen for the mount, BookmarkablePageLink can be used to insert a bookmarkable link to the request target.

This example demonstrates how to mount a path with QueryStringRequestTargetUrlCodingStrategy within the init method of a class implementing WebApplication:

mount(new QueryStringUrlCodingStrategy("/admin/productmanagement", admin.ProductManagement.class));

Note that, as with the main BookmarkablePageRequestTargetUrlCodingStrategy, if the output of this coding strategy is passed through HttpServletResponse.encodeURL and the client has cookies turned off, the client's session ID will be stored in a path parameter, like so:"/mywebapp/myservlet/admin/productmanagement;jsessionid=730EC527564AF1C73F8C2FB19B604F55?action=edit&product=4995" .

Author:
Benjamin Hawkes-Lewis

Field Summary
 
Fields inherited from class org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy
bookmarkablePageClassRef
 
Constructor Summary
QueryStringUrlCodingStrategy(String mountPath, Class bookmarkablePageClass)
          Sole constructor.
 
Method Summary
protected  void appendParameters(AppendingStringBuffer url, Map parameters)
          Append the parameters to the end of the URL.
 IRequestTarget decode(RequestParameters requestParameters)
          Gets the decoded request target.
protected  ValueMap decodeParameters(String fragment, Map passedParameters)
          Decodes parameters object from the provided query string
 
Methods inherited from class org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy
encode, matches, toString
 
Methods inherited from class org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy
appendPathParameter, getMountPath, matches, urlDecode, urlDecodePathComponent, urlDecodeQueryComponent, urlEncode, urlEncodePathComponent, urlEncodeQueryComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryStringUrlCodingStrategy

public QueryStringUrlCodingStrategy(String mountPath,
                                    Class bookmarkablePageClass)
Sole constructor.

Parameters:
mountPath - the relative reference URL on which the page is mounted
bookmarkablePageClass - the class of the mounted page
Method Detail

appendParameters

protected void appendParameters(AppendingStringBuffer url,
                                Map parameters)
Append the parameters to the end of the URL.

Overrides:
appendParameters in class AbstractRequestTargetUrlCodingStrategy
Parameters:
url - the relative reference URL
parameters - parameter names mapped to parameter values

decode

public IRequestTarget decode(RequestParameters requestParameters)
Description copied from interface: IRequestTargetUrlCodingStrategy
Gets the decoded request target.

Specified by:
decode in interface IRequestTargetUrlCodingStrategy
Overrides:
decode in class BookmarkablePageRequestTargetUrlCodingStrategy
Parameters:
requestParameters - the request parameters
Returns:
the decoded request target
See Also:
IRequestTargetUrlCodingStrategy.decode(org.apache.wicket.request.RequestParameters)

decodeParameters

protected ValueMap decodeParameters(String fragment,
                                    Map passedParameters)
Decodes parameters object from the provided query string

Overrides:
decodeParameters in class AbstractRequestTargetUrlCodingStrategy
Parameters:
fragment - contains the query string
passedParameters - parameters decoded by wicket before this method - usually off the query string
Returns:
Parameters


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