Class QueryStringUrlCodingStrategy

  extended by
      extended by
          extended by
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" .

Benjamin Hawkes-Lewis

Field Summary
Fields inherited from class
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
encode, matches, toString
Methods inherited from class
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


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

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


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

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


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

Specified by:
decode in interface IRequestTargetUrlCodingStrategy
decode in class BookmarkablePageRequestTargetUrlCodingStrategy
requestParameters - the request parameters
the decoded request target
See Also:


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

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

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