Module org.apache.wicket.core
Class AbstractBookmarkableMapper
java.lang.Object
org.apache.wicket.request.mapper.AbstractMapper
org.apache.wicket.core.request.mapper.AbstractComponentMapper
org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
- All Implemented Interfaces:
IRequestMapper
- Direct Known Subclasses:
BookmarkableMapper
,MountedMapper
,PackageMapper
,ResourceMapper
Abstract encoder for Bookmarkable, Hybrid and BookmarkableListener URLs.
- Author:
- Matej Knopp
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static final class
Represents information stored in URL. -
Field Summary
Modifier and TypeFieldDescriptionprotected final String[]
protected final IPageParametersEncoder
protected final List<AbstractBookmarkableMapper.MountPathSegment>
-
Constructor Summary
ConstructorDescriptionConstruct.AbstractBookmarkableMapper
(String mountPath, IPageParametersEncoder pageParametersEncoder) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Url
Builds URL for the givenAbstractBookmarkableMapper.UrlInfo
instance.protected boolean
checkPageClass
(Class<? extends IRequestablePage> pageClass) protected boolean
protected PageParameters
extractPageParameters
(Request request, Url url) Extracts the PageParameters from URL if there are anyint
getCompatibilityScore
(Request request) Returns the score representing how compatible this request mapper is to processing the given request.protected int[]
protected final PageInfo
getPageInfo
(IPageRequestHandler handler) protected List<AbstractBookmarkableMapper.MountPathSegment>
getPathSegments
(String[] segments) protected boolean
protected boolean
isFixedSegment
(String segment) mapHandler
(IRequestHandler requestHandler) mapRequest
(Request request) protected PageParameters
protected abstract boolean
Indicates whether hybridRenderPageRequestHandler
URL for page will be generated only if page has been created with bookmarkable URL.protected abstract AbstractBookmarkableMapper.UrlInfo
parseRequest
(Request request) Parse the given request to anAbstractBookmarkableMapper.UrlInfo
instance.protected IRequestHandler
processBookmarkable
(Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) Creates aIRequestHandler
that processes a bookmarkable request.protected IRequestHandler
processHybrid
(PageInfo pageInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount) Creates aIRequestHandler
that processes a hybrid request.protected IRequestHandler
processListener
(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) Creates aIRequestHandler
that notifies anIRequestListener
.protected Locale
OverrideAbstractMapper.resolveLocale()
to return the result of this method if you want to use the user's session or request locale for parsing numbers from the page parametersprotected boolean
segmentsMatch
(String mountedSegment, String urlSegment) Decides whether a segment from the mounted path matches with a segment from the requested url.setCaseSensitiveMatch
(boolean isCaseSensitive) Sets whether the matching of mounted segments against request's url ones should be case sensitive or not.protected boolean
setPlaceholders
(PageParameters parameters, Url url) Replaces mandatory and optional parameters with their values.protected boolean
Methods inherited from class org.apache.wicket.core.request.mapper.AbstractComponentMapper
cleanClassName, encodePageComponentInfo, getContext, getPageClass, getPageComponentInfo, removeMetaParameter
Methods inherited from class org.apache.wicket.request.mapper.AbstractMapper
encodePageParameters, extractPageParameters, getMountSegments, getOptionalPlaceholder, getPlaceholder, getPlaceholder, resolveLocale, safeSegmentGetter, urlStartsWith
-
Field Details
-
pathSegments
-
mountSegments
-
pageParametersEncoder
-
-
Constructor Details
-
AbstractBookmarkableMapper
public AbstractBookmarkableMapper()Construct. -
AbstractBookmarkableMapper
-
-
Method Details
-
parseRequest
Parse the given request to anAbstractBookmarkableMapper.UrlInfo
instance.- Parameters:
request
-- Returns:
- UrlInfo instance or
null
if this encoder can not handle the request
-
buildUrl
Builds URL for the givenAbstractBookmarkableMapper.UrlInfo
instance. The URL this method produces must be parseable by theparseRequest(Request)
method.- Parameters:
info
-- Returns:
- Url result URL
-
pageMustHaveBeenCreatedBookmarkable
Indicates whether hybridRenderPageRequestHandler
URL for page will be generated only if page has been created with bookmarkable URL.For generic bookmarkable encoders this method should return
true
. For explicit (mounted) encoders this method should returnfalse
- Returns:
true
if hybrid URL requires page created bookmarkable,false
otherwise.
-
getCompatibilityScore
Description copied from interface:IRequestMapper
Returns the score representing how compatible this request mapper is to processing the given request. When a request comes in all mappers are scored and are tried in order from highest score to lowest.A good criteria for calculating the score is the number of matched url segments. For example when there are two mappers for a mounted page, one mapped to
/foo
another to/foo/bar
and the incoming request URL is /foo/bar/baz, the mapping to/foo/bar
should probably handle the request first as it has matching segments count of 2 while the first one has only matching segments count of 1.Note that the method can return value greater then zero even if the mapper does not recognize the request.
- Returns:
- the compatibility score, e.g. count of matching segments
-
processBookmarkable
protected IRequestHandler processBookmarkable(Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) Creates aIRequestHandler
that processes a bookmarkable request.- Parameters:
pageClass
-pageParameters
-- Returns:
- a
IRequestHandler
capable of processing the bookmarkable request.
-
processHybrid
protected IRequestHandler processHybrid(PageInfo pageInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount) Creates aIRequestHandler
that processes a hybrid request. When the page identified bypageInfo
was not available, the request should be treated as a bookmarkable request.- Parameters:
pageInfo
-pageClass
-pageParameters
-renderCount
-- Returns:
- a
IRequestHandler
capable of processing the hybrid request.
-
processListener
protected IRequestHandler processListener(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) Creates aIRequestHandler
that notifies anIRequestListener
.- Parameters:
pageComponentInfo
-pageClass
-pageParameters
-- Returns:
- a
IRequestHandler
that notifies anIRequestListener
.
-
mapRequest
Description copied from interface:IRequestMapper
- Parameters:
request
- provides access to request data (i.e. Url and Parameters)- Returns:
- RequestHandler instance or
null
-
checkPageInstance
-
checkPageClass
-
mapHandler
Description copied from interface:IRequestMapper
- Returns:
- Url instance or
null
.
-
getPageInfo
-
newPageParameters
- Returns:
- a new instance of
PageParameters
that will be passed to the page/resource
-
resolveUserLocale
OverrideAbstractMapper.resolveLocale()
to return the result of this method if you want to use the user's session or request locale for parsing numbers from the page parameters- Returns:
- the Session or Request's locale to use for parsing any numbers in the request parameters
-
getPathSegments
-
isFixedSegment
-
extractPageParameters
Extracts the PageParameters from URL if there are any -
getMatchedSegmentSizes
-
segmentsMatch
Decides whether a segment from the mounted path matches with a segment from the requested url. A custom implementation of this class may use more complex logic to handle spelling errors- Parameters:
mountedSegment
- the segment from the mounted pathurlSegment
- the segment from the request url- Returns:
true
if the segments match
-
isCaseSensitiveMatch
- Returns:
- whether the matching of mounted segments against request's url ones should be case sensitive or not
-
setCaseSensitiveMatch
Sets whether the matching of mounted segments against request's url ones should be case sensitive or not.- Parameters:
isCaseSensitive
- a flag indicating whether the matching of mounted segments against request's url ones should be case sensitive or not- Returns:
- this instance, for chaining
-
setPlaceholders
Replaces mandatory and optional parameters with their values. If a mandatory parameter is not provided then the method returnsfalse
indicating that there is a problem. Optional parameters with missing values are just dropped.- Parameters:
parameters
- The parameters with the valuesurl
- The url with the placeholders- Returns:
true
if all mandatory parameters are properly substituted,false
- otherwise
-
urlStartsWithMountedSegments
-