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

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

public class MixedParamHybridUrlCodingStrategy
extends HybridUrlCodingStrategy

Url coding strategy for bookmarkable pages with Ajax components that encodes a set of given parameters in the url's path and the rest in the query-string. In addition, the page version is added to the end of the url's path.

Strategy looks for path-parameters whose name is read from an array of names e.g. ["param0", "param1"]. Found parameters will be appended to the url in the form /mount-path/paramvalue0/paramvalue1.

All other parameters are added as parameter in the form: /mount-path/paramvalue0?otherparam0=otherparamvalue0&otherparam1=otherparamvalue1.

Decode is symmetric except for when a path parameter that is not at the end has no value during encode. For example, the names for the path parameters are: "a", "b" and "c". When "b" is not specified upon encoding, but "c" is, upon a decode "b" will get the empty string as value. When both "b" and "c" are missing on encode, the will not get a value during decode.

Author:
erik.van.oosten
See Also:
MixedParamUrlCodingStrategy

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.request.target.coding.HybridUrlCodingStrategy
HybridUrlCodingStrategy.HybridBookmarkablePageRequestTarget, HybridUrlCodingStrategy.PageInfo, HybridUrlCodingStrategy.PageInfoExtraction
 
Field Summary
 
Fields inherited from class org.apache.wicket.request.target.coding.HybridUrlCodingStrategy
PAGE_PARAMETERS_META_DATA_KEY, pageClassRef
 
Constructor Summary
MixedParamHybridUrlCodingStrategy(String mountPath, Class<? extends Page> pageClass, boolean redirectOnBookmarkableRequest, String[] parameterNames)
          Construct.
MixedParamHybridUrlCodingStrategy(String mountPath, Class<? extends Page> pageClass, String[] parameterNames)
          Construct.
 
Method Summary
protected  String addPageInfo(String url, HybridUrlCodingStrategy.PageInfo pageInfo)
          Encodes the PageInfo part to the URL
protected  void appendParameters(AppendingStringBuffer url, Map<String,?> parameters)
          Encodes Map into a url fragment and append that to the provided url buffer.
protected  ValueMap decodeParameters(String urlFragment, Map<String,?> urlParameters)
          Decodes parameters object from the provided url fragment
 MixedParamHybridUrlCodingStrategy setIgnoreUndeclaredParameters(boolean ignoreUndeclaredParameters)
           
 
Methods inherited from class org.apache.wicket.request.target.coding.HybridUrlCodingStrategy
alwaysRedirectWhenPageMapIsSpecified, decode, encode, extractPageInfo, getBeginSeparator, getEndSeparator, getInitialPagePageParameters, handleExpiredPage, isRedirectOnBookmarkableRequest, matches, matches, setInitialPageParameters, toString, urlDecodePathComponent, urlEncodePathComponent
 
Methods inherited from class org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy
appendPathParameter, getMountPath, urlDecode, urlDecodeQueryComponent, urlEncode, urlEncodeQueryComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MixedParamHybridUrlCodingStrategy

public MixedParamHybridUrlCodingStrategy(String mountPath,
                                         Class<? extends Page> pageClass,
                                         boolean redirectOnBookmarkableRequest,
                                         String[] parameterNames)
Construct.

Parameters:
mountPath - mount path
pageClass - class of mounted page
redirectOnBookmarkableRequest - whether after hitting the page with URL in bookmarkable form it should be redirected to hybrid URL - needed for ajax to work properly after page refresh
parameterNames - the parameter names (not null)

MixedParamHybridUrlCodingStrategy

public MixedParamHybridUrlCodingStrategy(String mountPath,
                                         Class<? extends Page> pageClass,
                                         String[] parameterNames)
Construct.

Parameters:
mountPath - mount path
pageClass - class of mounted page
parameterNames - the parameter names (not null)
Method Detail

setIgnoreUndeclaredParameters

public MixedParamHybridUrlCodingStrategy setIgnoreUndeclaredParameters(boolean ignoreUndeclaredParameters)
Parameters:
ignoreUndeclaredParameters - true to ignore undeclared parameters in the URL (still logged), false to throw an exception when this happens (default is true)
Returns:
this

appendParameters

protected void appendParameters(AppendingStringBuffer url,
                                Map<String,?> parameters)
Encodes Map into a url fragment and append that to the provided url buffer.

Overrides:
appendParameters in class AbstractRequestTargetUrlCodingStrategy
Parameters:
url - url so far
parameters - Map object to be encoded

addPageInfo

protected String addPageInfo(String url,
                             HybridUrlCodingStrategy.PageInfo pageInfo)
Encodes the PageInfo part to the URL

Overrides:
addPageInfo in class HybridUrlCodingStrategy
Returns:
URL

decodeParameters

protected ValueMap decodeParameters(String urlFragment,
                                    Map<String,?> urlParameters)
Decodes parameters object from the provided url fragment

Overrides:
decodeParameters in class AbstractRequestTargetUrlCodingStrategy
Parameters:
urlFragment - fragment of the url after the decoded path and before the query string
urlParameters - query string parameters
Returns:
Parameters created from the url fragment and query string


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