org.wicketstuff.minis.mapper
Class ExtendedPackageMapper

java.lang.Object
  extended by org.apache.wicket.request.mapper.AbstractMapper
      extended by org.wicketstuff.minis.mapper.ExtendedPackageMapper
All Implemented Interfaces:
IRequestMapper

public class ExtendedPackageMapper
extends AbstractMapper

Extended PackageMapper with Named Parameter and HomePage support. Remember to add this mapper before anyone else, so it will have low priority against top-level, more important mappers.

Usage:

 add(new ExtendedPackageMapper("${username}/static/${group}", Profile.class) {
          protected boolean validateParameters(PageParameters parameters) { 
             String username = parameters.get("username").toString(); 
             String group = parameters.get("group").toString();
             return validUsername(username)
          }
 });
 

Users can then use URLs like:

Parameters can be accessed as usual (PageParameters in constructor, for example)

Author:
Bruno Borges

Constructor Summary
ExtendedPackageMapper(String mountPath, Class<P> homePage)
           Construct an ExtendedPackageMapper for package of homePage class, at mountPath.
 
Method Summary
 int getCompatibilityScore(Request request)
          Scores the compatibility of Request with this Mapper.
 Url mapHandler(IRequestHandler requestHandler)
           
 IRequestHandler mapRequest(Request request)
           
protected  boolean validateParameters(PageParameters parameters)
          Override this to validate parameters.
 
Methods inherited from class org.apache.wicket.request.mapper.AbstractMapper
encodePageParameters, extractPageParameters, getMountSegments, getOptionalPlaceholder, getPlaceholder, getPlaceholder, removeMetaParameter, urlStartsWith
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedPackageMapper

public ExtendedPackageMapper(String mountPath,
                             Class<P> homePage)

Construct an ExtendedPackageMapper for package of homePage class, at mountPath. homePage is considered the Home Page for this mounted path, in case the user does not indicate which page to render.

Named parameters are optional and may be defined as the first mount segment

Parameters:
mountPath - in the form of "${some}/path/with/${named}/parameters"
homePage -
Method Detail

mapHandler

public Url mapHandler(IRequestHandler requestHandler)

validateParameters

protected boolean validateParameters(PageParameters parameters)
Override this to validate parameters. Return true if this Mapper should handle the current request based on your busines slogic

Parameters:
parameters -
Returns:
true if this Mapper will handle the request. default: true

mapRequest

public IRequestHandler mapRequest(Request request)

getCompatibilityScore

public int getCompatibilityScore(Request request)
Scores the compatibility of Request with this Mapper.



Copyright © 2014. All rights reserved.