Class MountedMapper
- java.lang.Object
-
- org.apache.wicket.request.mapper.AbstractMapper
-
- org.apache.wicket.core.request.mapper.AbstractComponentMapper
-
- org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
-
- org.apache.wicket.core.request.mapper.MountedMapper
-
- All Implemented Interfaces:
IRequestMapper
- Direct Known Subclasses:
HomePageMapper
public class MountedMapper extends AbstractBookmarkableMapper
Encoder for mounted URL. The mount path can contain parameter placeholders, i.e./mount/${foo}/path
. In that case the appropriate segment from the URL will be accessible as named parameter "foo" in thePageParameters
. Similarly when the URL is constructed, the second segment will contain the value of the "foo" named page parameter. Optional parameters are denoted by using a # instead of $:/mount/#{foo}/path/${bar}
has an optionalfoo
parameter, a fixed/path/
part and a requiredbar
parameter. When in doubt, parameters are matched from left to right, where required parameters are matched before optional parameters, and optional parameters eager (from left to right).Decodes and encodes the following URLs:
Page Class - Render (BookmarkablePageRequestHandler for mounted pages) /mount/point (these will redirect to hybrid alternative if page is not stateless) IPage Instance - Render Hybrid (RenderPageRequestHandler for mounted pages) /mount/point?2 IPage Instance - Bookmarkable Listener (BookmarkableListenerRequestHandler for mounted pages) /mount/point?2-click-foo-bar-baz /mount/point?2-5.click.1-foo-bar-baz (1 is behavior index, 5 is render count) (these will redirect to hybrid if page is not stateless)
- Author:
- Matej Knopp
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
AbstractBookmarkableMapper.MountPathSegment, AbstractBookmarkableMapper.UrlInfo
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
mountSegments, pageParametersEncoder, pathSegments
-
-
Constructor Summary
Constructors Constructor Description MountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass)
Construct.MountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass, IPageParametersEncoder pageParametersEncoder)
Construct.MountedMapper(String mountPath, Supplier<Class<? extends IRequestablePage>> pageClassProvider)
Construct.MountedMapper(String mountPath, Supplier<Class<? extends IRequestablePage>> pageClassProvider, IPageParametersEncoder pageParametersEncoder)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Url
buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Builds URL for the givenAbstractBookmarkableMapper.UrlInfo
instance.protected boolean
checkPageClass(Class<? extends IRequestablePage> pageClass)
Url
mapHandler(IRequestHandler requestHandler)
protected boolean
pageMustHaveBeenCreatedBookmarkable()
Indicates whether hybridRenderPageRequestHandler
URL for page will be generated only if page has been created with bookmarkable URL.protected AbstractBookmarkableMapper.UrlInfo
parseRequest(Request request)
Parse the given request to anAbstractBookmarkableMapper.UrlInfo
instance.protected boolean
redirectFromHomePage()
If this method returnstrue
and application home page class is same as the class mounted with this encoder, request to home page will result in a redirect to the mounted path.String
toString()
-
Methods inherited from class org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
checkPageInstance, extractPageParameters, getCompatibilityScore, getMatchedSegmentSizes, getPageInfo, getPathSegments, isCaseSensitiveMatch, isFixedSegment, mapRequest, newPageParameters, processBookmarkable, processHybrid, processListener, resolveUserLocale, segmentsMatch, setCaseSensitiveMatch, setPlaceholders, urlStartsWithMountedSegments
-
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
-
-
-
-
Constructor Detail
-
MountedMapper
public MountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass)
Construct.- Parameters:
mountPath
-pageClass
-
-
MountedMapper
public MountedMapper(String mountPath, Supplier<Class<? extends IRequestablePage>> pageClassProvider)
Construct.- Parameters:
mountPath
-pageClassProvider
-
-
MountedMapper
public MountedMapper(String mountPath, Class<? extends IRequestablePage> pageClass, IPageParametersEncoder pageParametersEncoder)
Construct.- Parameters:
mountPath
-pageClass
-pageParametersEncoder
-
-
MountedMapper
public MountedMapper(String mountPath, Supplier<Class<? extends IRequestablePage>> pageClassProvider, IPageParametersEncoder pageParametersEncoder)
Construct.- Parameters:
mountPath
-pageClassProvider
-pageParametersEncoder
-
-
-
Method Detail
-
parseRequest
protected AbstractBookmarkableMapper.UrlInfo parseRequest(Request request)
Description copied from class:AbstractBookmarkableMapper
Parse the given request to anAbstractBookmarkableMapper.UrlInfo
instance.- Specified by:
parseRequest
in classAbstractBookmarkableMapper
- Returns:
- UrlInfo instance or
null
if this encoder can not handle the request
-
mapHandler
public Url mapHandler(IRequestHandler requestHandler)
Description copied from interface:IRequestMapper
- Specified by:
mapHandler
in interfaceIRequestMapper
- Overrides:
mapHandler
in classAbstractBookmarkableMapper
- Returns:
- Url instance or
null
.
-
buildUrl
protected Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Description copied from class:AbstractBookmarkableMapper
Builds URL for the givenAbstractBookmarkableMapper.UrlInfo
instance. The URL this method produces must be parseable by theAbstractBookmarkableMapper.parseRequest(Request)
method.- Specified by:
buildUrl
in classAbstractBookmarkableMapper
- Returns:
- Url result URL
- See Also:
AbstractBookmarkableMapper.buildUrl(AbstractBookmarkableMapper.UrlInfo)
-
redirectFromHomePage
protected boolean redirectFromHomePage()
If this method returnstrue
and application home page class is same as the class mounted with this encoder, request to home page will result in a redirect to the mounted path.- Returns:
- whether this encode should respond to home page request when home page class is same as mounted class.
-
pageMustHaveBeenCreatedBookmarkable
protected boolean pageMustHaveBeenCreatedBookmarkable()
Description copied from class:AbstractBookmarkableMapper
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
- Specified by:
pageMustHaveBeenCreatedBookmarkable
in classAbstractBookmarkableMapper
- Returns:
true
if hybrid URL requires page created bookmarkable,false
otherwise.- See Also:
AbstractBookmarkableMapper.pageMustHaveBeenCreatedBookmarkable()
-
checkPageClass
protected boolean checkPageClass(Class<? extends IRequestablePage> pageClass)
- Overrides:
checkPageClass
in classAbstractBookmarkableMapper
- See Also:
AbstractBookmarkableMapper.checkPageClass(java.lang.Class)
-
-