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

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

public class IndexedSharedResourceCodingStrategy
extends AbstractRequestTargetUrlCodingStrategy

Indexed url encoding for shared resources with optional query parameters

for example, with this url

   /mountpath/foo/bar/baz?name=joe&languages=java&languages=scala
 
the parameters value map will be

Key Value
"0" "foo"
"1" "bar"
"2" "baz"
"name" "joe"
"languages" String[] { "java", "scala" }
so you can have urls like these /images/{imagename}.{format} /blog/2008/05/12/47-test-blog-entry.html with absolutely no effort.

Can be used in WebApplication like this: mount(new IndexedSharedResourceCodingStrategy(path, sharedResourceKey);

The greatest benefit is that shared resource urls look like static resources for the browser. This comes especially handy when utilizing browser caching. Also, the user will not realize the resources are served dynamically and bookmarking is easy.


Constructor Summary
IndexedSharedResourceCodingStrategy(String mountPath, String resourceKey)
          mount resource with specified key under indexed path
 
Method Summary
 IRequestTarget decode(RequestParameters requestParameters)
          Gets the decoded request target.
protected  ValueMap decodeParameters(String path, Map<String,?> queryParameters)
          Decodes parameters object from the provided url fragment
 CharSequence encode(IRequestTarget requestTarget)
          Gets the encoded url for the provided request target.
 boolean matches(IRequestTarget requestTarget)
          Gets whether this mounter is applicable for the provided request target.
 
Methods inherited from class org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy
appendParameters, appendPathParameter, getMountPath, matches, urlDecode, urlDecodePathComponent, urlDecodeQueryComponent, urlEncode, urlEncodePathComponent, urlEncodeQueryComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexedSharedResourceCodingStrategy

public IndexedSharedResourceCodingStrategy(String mountPath,
                                           String resourceKey)
mount resource with specified key under indexed path

Parameters:
mountPath - path the resource will be mounted to
resourceKey - key of the resource
Method Detail

encode

public CharSequence encode(IRequestTarget requestTarget)
Description copied from interface: IRequestTargetUrlCodingStrategy
Gets the encoded url for the provided request target. Typically, the result will be prepended with a protocol specific prefix. In a servlet environment, the prefix typically is the context-path + servlet path, eg mywebapp/myservletname.

Parameters:
requestTarget - the request target to encode
Returns:
the encoded url
See Also:
IRequestTargetUrlCodingStrategy.encode(org.apache.wicket.IRequestTarget)

decode

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

Parameters:
requestParameters - the request parameters
Returns:
the decoded request target
See Also:
IRequestTargetUrlCodingStrategy.decode(org.apache.wicket.request.RequestParameters)

decodeParameters

protected ValueMap decodeParameters(String path,
                                    Map<String,?> queryParameters)
Description copied from class: AbstractRequestTargetUrlCodingStrategy
Decodes parameters object from the provided url fragment

Overrides:
decodeParameters in class AbstractRequestTargetUrlCodingStrategy
Parameters:
path - fragment of the url after the decoded path and before the query string
queryParameters - query string parameters
Returns:
Parameters created from the url fragment and query string
See Also:
AbstractRequestTargetUrlCodingStrategy.decodeParameters(java.lang.String, java.util.Map)

matches

public boolean matches(IRequestTarget requestTarget)
Description copied from interface: IRequestTargetUrlCodingStrategy
Gets whether this mounter is applicable for the provided request target.

Parameters:
requestTarget - the request target
Returns:
whether this mounter is applicable for the provided request target
See Also:
IRequestTargetUrlCodingStrategy.matches(org.apache.wicket.IRequestTarget)


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