|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy org.apache.wicket.request.target.coding.HybridUrlCodingStrategy
public class HybridUrlCodingStrategy
An URL coding strategy that encodes the mount point, page parameters and page instance
information into the URL. The benefits compared to mounting page with
BookmarkablePageRequestTargetUrlCodingStrategy
are that the mount point is preserved even
after invoking listener interfaces (thus you don't lose bookmarkability after clicking links) and
that for ajax only pages the state is preserved on refresh.
The url with HybridUrlCodingStrategy
looks like /mount/path/param1/value1.3. or
/mount/path/param1/value1.3.2 where 3 is page Id and 2 is version number.
Also to preserve state on refresh with ajax-only pages the HybridUrlCodingStrategy
does
an immediate redirect after hitting bookmarkable URL, e.g. it immediately redirects from
/mount/path to /mount/path.3 where 3 is the next page id. This preserves the page instance on
subsequent page refresh.
Nested Class Summary | |
---|---|
static class |
HybridUrlCodingStrategy.HybridBookmarkablePageRequestTarget
BookmarkablePage request target that does a redirect after bookmarkable page was rendered (only if the bookmarkable page is stateful though) |
protected static class |
HybridUrlCodingStrategy.PageInfo
Possible string representation of PageInfo: pageId pageId.version pageMap (only if pageMap starts with a letter) .pageMap pageMap.pageId.version pageMap.pageId (only if pageMap name starts with a letter) |
protected static class |
HybridUrlCodingStrategy.PageInfoExtraction
Class that encapsulates HybridUrlCodingStrategy.PageInfo instance and the URL part prior the PageInfo part |
Field Summary | |
---|---|
static org.apache.wicket.request.target.coding.HybridUrlCodingStrategy.PageParametersMetaDataKey |
PAGE_PARAMETERS_META_DATA_KEY
Meta data key to store PageParameters in page instance. |
protected WeakReference<Class<? extends Page>> |
pageClassRef
bookmarkable page class. |
Constructor Summary | |
---|---|
HybridUrlCodingStrategy(String mountPath,
Class<? extends Page> pageClass)
Construct. |
|
HybridUrlCodingStrategy(String mountPath,
Class<? extends Page> pageClass,
boolean redirectOnBookmarkableRequest)
Construct. |
Method Summary | |
---|---|
protected String |
addPageInfo(String url,
HybridUrlCodingStrategy.PageInfo pageInfo)
Encodes the PageInfo part to the URL |
protected boolean |
alwaysRedirectWhenPageMapIsSpecified()
Returns whether to redirect when there is pageMap specified in bookmarkable URL |
IRequestTarget |
decode(RequestParameters requestParameters)
Gets the decoded request target. |
CharSequence |
encode(IRequestTarget requestTarget)
Gets the encoded url for the provided request target. |
protected HybridUrlCodingStrategy.PageInfoExtraction |
extractPageInfo(String url)
Extracts the PageInfo string. |
protected String |
getBeginSeparator()
|
protected String |
getEndSeparator()
|
static PageParameters |
getInitialPagePageParameters(Page page)
|
protected IRequestTarget |
handleExpiredPage(String pageMapName,
Class<? extends Page> pageClass,
int trailingSlashesCount,
boolean redirect)
Handles the case where a non-bookmarkable url with a hybrid base refers to a page that is no longer in session. |
protected boolean |
isRedirectOnBookmarkableRequest()
Returns whether after hitting bookmarkable url the request should be redirected to a hybrid URL. |
boolean |
matches(IRequestTarget requestTarget)
Gets whether this mounter is applicable for the provided request target. |
boolean |
matches(String path,
boolean caseSensitive)
Does given path match this mount? We match /mount/point or /mount/point/with/extra/path, but not /mount/pointXXX. |
static void |
setInitialPageParameters(Page page,
PageParameters pageParameters)
Sets the initial page parameters for page instance. |
String |
toString()
|
protected String |
urlDecodePathComponent(String value)
Returns a decoded value of the given value (taken from a URL path section) |
protected String |
urlEncodePathComponent(String string)
Url encodes a string that is mean for a URL path (e.g., between slashes) |
Methods inherited from class org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy |
---|
appendParameters, appendPathParameter, decodeParameters, getMountPath, urlDecode, urlDecodeQueryComponent, urlEncode, urlEncodeQueryComponent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final WeakReference<Class<? extends Page>> pageClassRef
public static final org.apache.wicket.request.target.coding.HybridUrlCodingStrategy.PageParametersMetaDataKey PAGE_PARAMETERS_META_DATA_KEY
Constructor Detail |
---|
public HybridUrlCodingStrategy(String mountPath, Class<? extends Page> pageClass, boolean redirectOnBookmarkableRequest)
mountPath
- pageClass
- 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 refreshpublic HybridUrlCodingStrategy(String mountPath, Class<? extends Page> pageClass)
mountPath
- pageClass
- Method Detail |
---|
public static void setInitialPageParameters(Page page, PageParameters pageParameters)
page
- pageParameters
- public static PageParameters getInitialPagePageParameters(Page page)
page
-
protected boolean isRedirectOnBookmarkableRequest()
protected boolean alwaysRedirectWhenPageMapIsSpecified()
public IRequestTarget decode(RequestParameters requestParameters)
IRequestTargetUrlCodingStrategy
requestParameters
- the request parameters
IRequestTargetUrlCodingStrategy.decode(org.apache.wicket.request.RequestParameters)
protected IRequestTarget handleExpiredPage(String pageMapName, Class<? extends Page> pageClass, int trailingSlashesCount, boolean redirect)
/context/hybrid-mount.0.23?wicket:interface=...
. The
default behavior is to throw a PageExpiredException
.
This method can be overwritten to, for example, return the user to a new instance of the
bookmarkable page that was mounted using hybrid strategy - this, however, should only be used
in cases where the page expects no page parameters because they are no longer available.
pageMapName
- page map name this page is mounted inpageClass
- class of mounted pagetrailingSlashesCount
- count of trailing slsahes in the urlredirect
- whether or not a redirect should be issued
public CharSequence encode(IRequestTarget requestTarget)
IRequestTargetUrlCodingStrategy
requestTarget
- the request target to encode
IRequestTargetUrlCodingStrategy.encode(org.apache.wicket.IRequestTarget)
protected String urlEncodePathComponent(String string)
AbstractRequestTargetUrlCodingStrategy
urlEncodePathComponent
in class AbstractRequestTargetUrlCodingStrategy
string
- string to be encoded
protected String urlDecodePathComponent(String value)
AbstractRequestTargetUrlCodingStrategy
urlDecodePathComponent
in class AbstractRequestTargetUrlCodingStrategy
public boolean matches(IRequestTarget requestTarget)
IRequestTargetUrlCodingStrategy
requestTarget
- the request target
IRequestTargetUrlCodingStrategy.matches(org.apache.wicket.IRequestTarget)
protected HybridUrlCodingStrategy.PageInfoExtraction extractPageInfo(String url)
url
-
protected String getBeginSeparator()
protected String getEndSeparator()
protected String addPageInfo(String url, HybridUrlCodingStrategy.PageInfo pageInfo)
url
- pageInfo
-
public boolean matches(String path, boolean caseSensitive)
AbstractRequestTargetUrlCodingStrategy
matches
in interface IRequestTargetUrlCodingStrategy
matches
in class AbstractRequestTargetUrlCodingStrategy
caseSensitive
- whether the strategy should treat path
argument with case sensitivity
or not
AbstractRequestTargetUrlCodingStrategy.matches(String,
boolean)
public String toString()
toString
in class Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |