org.apache.wicket.request.mapper
Class MountedMapper

java.lang.Object
  extended by org.apache.wicket.request.mapper.AbstractMapper
      extended by org.apache.wicket.request.mapper.AbstractComponentMapper
          extended by org.apache.wicket.request.mapper.AbstractBookmarkableMapper
              extended by org.apache.wicket.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 the PageParameters. 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 optional foo parameter, a fixed /path/ part and a required bar 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 (BookmarkableListenerInterfaceRequestHandler 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.request.mapper.AbstractBookmarkableMapper
AbstractBookmarkableMapper.UrlInfo
 
Constructor Summary
MountedMapper(java.lang.String mountPath, java.lang.Class<? extends IRequestablePage> pageClass)
          Construct.
MountedMapper(java.lang.String mountPath, java.lang.Class<? extends IRequestablePage> pageClass, IPageParametersEncoder pageParametersEncoder)
          Construct.
MountedMapper(java.lang.String mountPath, ClassProvider<? extends IRequestablePage> pageClassProvider)
          Construct.
MountedMapper(java.lang.String mountPath, ClassProvider<? extends IRequestablePage> pageClassProvider, IPageParametersEncoder pageParametersEncoder)
          Construct.
 
Method Summary
protected  Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
          Builds URL for the given AbstractBookmarkableMapper.UrlInfo instance.
protected  boolean checkPageClass(java.lang.Class<? extends IRequestablePage> pageClass)
           
 int getCompatibilityScore(Request request)
          Returns the score representing how compatible this request mapper is to processing the given request.
 Url mapHandler(IRequestHandler requestHandler)
          Returns the Url for given IRequestHandler or null if the request handler is not recognized.
protected  PageParameters newPageParameters()
           
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  boolean redirectFromHomePage()
          If this method returns true 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.
 java.lang.String toString()
           
protected  boolean urlStartsWith(Url url, java.lang.String... segments)
          Returns true if the given url starts with specified segments.
 
Methods inherited from class org.apache.wicket.request.mapper.AbstractBookmarkableMapper
mapRequest, processBookmarkable, processHybrid, processListener
 
Methods inherited from class org.apache.wicket.request.mapper.AbstractComponentMapper
encodePageComponentInfo, getContext, getPageClass, getPageComponentInfo, removeMetaParameter, requestListenerInterfaceFromString, requestListenerInterfaceToString
 
Methods inherited from class org.apache.wicket.request.mapper.AbstractMapper
encodePageParameters, extractPageParameters, getMountSegments, getOptionalPlaceholder, getPlaceholder, getPlaceholder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MountedMapper

public MountedMapper(java.lang.String mountPath,
                     java.lang.Class<? extends IRequestablePage> pageClass)
Construct.

Parameters:
mountPath -
pageClass -

MountedMapper

public MountedMapper(java.lang.String mountPath,
                     ClassProvider<? extends IRequestablePage> pageClassProvider)
Construct.

Parameters:
mountPath -
pageClassProvider -

MountedMapper

public MountedMapper(java.lang.String mountPath,
                     java.lang.Class<? extends IRequestablePage> pageClass,
                     IPageParametersEncoder pageParametersEncoder)
Construct.

Parameters:
mountPath -
pageClass -
pageParametersEncoder -

MountedMapper

public MountedMapper(java.lang.String mountPath,
                     ClassProvider<? 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 an AbstractBookmarkableMapper.UrlInfo instance.

Specified by:
parseRequest in class AbstractBookmarkableMapper
Returns:
UrlInfo instance or null if this encoder can not handle the request
See Also:
AbstractBookmarkableMapper.parseRequest(org.apache.wicket.request.Request)

urlStartsWith

protected boolean urlStartsWith(Url url,
                                java.lang.String... segments)
Description copied from class: AbstractMapper
Returns true if the given url starts with specified segments. Segments that contain placelhoders are not compared.

Overrides:
urlStartsWith in class AbstractMapper
Returns:
true if the URL starts with the specified segments, false otherwise

newPageParameters

protected PageParameters newPageParameters()

mapHandler

public Url mapHandler(IRequestHandler requestHandler)
Description copied from class: AbstractBookmarkableMapper
Returns the Url for given IRequestHandler or null if the request handler is not recognized.

Specified by:
mapHandler in interface IRequestMapper
Overrides:
mapHandler in class AbstractBookmarkableMapper
Returns:
Url instance or null.

buildUrl

protected Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Description copied from class: AbstractBookmarkableMapper
Builds URL for the given AbstractBookmarkableMapper.UrlInfo instance. The URL this method produces must be parseable by the AbstractBookmarkableMapper.parseRequest(Request) method.

Specified by:
buildUrl in class AbstractBookmarkableMapper
Returns:
Url result URL
See Also:
AbstractBookmarkableMapper.buildUrl(org.apache.wicket.request.mapper.AbstractBookmarkableMapper.UrlInfo)

redirectFromHomePage

protected boolean redirectFromHomePage()
If this method returns true 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 hybrid 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

Specified by:
pageMustHaveBeenCreatedBookmarkable in class AbstractBookmarkableMapper
Returns:
true if hybrid URL requires page created bookmarkable, false otherwise.
See Also:
AbstractBookmarkableMapper.pageMustHaveBeenCreatedBookmarkable()

getCompatibilityScore

public int getCompatibilityScore(Request request)
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.

Specified by:
getCompatibilityScore in interface IRequestMapper
Specified by:
getCompatibilityScore in class AbstractBookmarkableMapper
Returns:
the compatibility score, e.g. count of matching segments
See Also:
AbstractBookmarkableMapper.getCompatibilityScore(org.apache.wicket.request.Request)

checkPageClass

protected boolean checkPageClass(java.lang.Class<? extends IRequestablePage> pageClass)
Overrides:
checkPageClass in class AbstractBookmarkableMapper
See Also:
AbstractBookmarkableMapper.checkPageClass(java.lang.Class)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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