public class ResourceMapper extends AbstractBookmarkableMapper
IRequestMapper
to mount resources to a custom mount path
/myresources/${category}/images/[indexed-param-0]/[indexed-param-1]?[named-param-1=value]&[named-param-2=value2]
mountResource("/images", new ImagesResourceReference()));Note: Mounted this way the resource reference has application scope, i.e. it is shared between all users of the application. It is recommended to not keep any state in it.
WebApplication.mountResource(String,
org.apache.wicket.request.resource.ResourceReference)
AbstractBookmarkableMapper.MountPathSegment, AbstractBookmarkableMapper.UrlInfo
pageParametersEncoder, pathSegments
Constructor and Description |
---|
ResourceMapper(String path,
ResourceReference resourceReference)
create a resource mapper for a resource
|
ResourceMapper(String path,
ResourceReference resourceReference,
IPageParametersEncoder encoder)
create a resource mapper for a resource
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCachingDecoration(Url url,
PageParameters parameters) |
protected Url |
buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Builds URL for the given
AbstractBookmarkableMapper.UrlInfo instance. |
protected IResourceCachingStrategy |
getCachingStrategy() |
int |
getCompatibilityScore(Request request)
Returns the score representing how compatible this request mapper is to processing the given
request.
|
Url |
mapHandler(IRequestHandler requestHandler)
|
IRequestHandler |
mapRequest(Request request)
|
protected boolean |
pageMustHaveBeenCreatedBookmarkable()
Indicates whether hybrid
RenderPageRequestHandler 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 an
AbstractBookmarkableMapper.UrlInfo instance. |
protected void |
removeCachingDecoration(Url url,
PageParameters parameters) |
checkPageClass, checkPageInstance, extractPageParameters, getMatchedSegmentSizes, getPageInfo, getPathSegments, isCaseSensitiveMatch, isFixedSegment, newPageParameters, processBookmarkable, processHybrid, processListener, resolveUserLocale, segmentsMatch, setCaseSensitiveMatch, setPlaceholders, urlStartsWithMountedSegments
cleanClassName, encodePageComponentInfo, getContext, getPageClass, getPageComponentInfo, removeMetaParameter
encodePageParameters, extractPageParameters, getMountSegments, getOptionalPlaceholder, getPlaceholder, getPlaceholder, resolveLocale, safeSegmentGetter, urlStartsWith
public ResourceMapper(String path, ResourceReference resourceReference)
path
- mount path for the resourceresourceReference
- resource reference that should be linked to the mount pathResourceMapper(String, org.apache.wicket.request.resource.ResourceReference,
org.apache.wicket.request.mapper.parameter.IPageParametersEncoder)
public ResourceMapper(String path, ResourceReference resourceReference, IPageParametersEncoder encoder)
path
- mount path for the resourceresourceReference
- resource reference that should be linked to the mount pathencoder
- encoder for url parameterspublic IRequestHandler mapRequest(Request request)
IRequestMapper
mapRequest
in interface IRequestMapper
mapRequest
in class AbstractBookmarkableMapper
request
- provides access to request data (i.e. Url and Parameters)null
protected final AbstractBookmarkableMapper.UrlInfo parseRequest(Request request)
AbstractBookmarkableMapper
AbstractBookmarkableMapper.UrlInfo
instance.parseRequest
in class AbstractBookmarkableMapper
null
if this encoder can not handle the requestprotected final Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
AbstractBookmarkableMapper
AbstractBookmarkableMapper.UrlInfo
instance. The URL this method produces must be
parseable by the AbstractBookmarkableMapper.parseRequest(Request)
method.buildUrl
in class AbstractBookmarkableMapper
protected final boolean pageMustHaveBeenCreatedBookmarkable()
AbstractBookmarkableMapper
RenderPageRequestHandler
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 return false
pageMustHaveBeenCreatedBookmarkable
in class AbstractBookmarkableMapper
true
if hybrid URL requires page created bookmarkable,
false
otherwise.public int getCompatibilityScore(Request request)
IRequestMapper
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.
getCompatibilityScore
in interface IRequestMapper
getCompatibilityScore
in class AbstractBookmarkableMapper
public Url mapHandler(IRequestHandler requestHandler)
IRequestMapper
mapHandler
in interface IRequestMapper
mapHandler
in class AbstractBookmarkableMapper
null
.protected IResourceCachingStrategy getCachingStrategy()
protected void addCachingDecoration(Url url, PageParameters parameters)
protected void removeCachingDecoration(Url url, PageParameters parameters)
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.