You need to setup it as root mapper. This way it will be asked first to map the request.
On Tue, Sep 6, 2011 at 10:16 AM, Mike Mander <[email protected]> wrote: > Sorry Martin, but i don't get it to work. > > I wrote a mapper: > > import org.apache.wicket.request.IRequestHandler; > import org.apache.wicket.request.Request; > import org.apache.wicket.request.Url; > import org.apache.wicket.request.handler.BookmarkablePageRequestHandler; > import org.apache.wicket.request.handler.PageProvider; > import org.apache.wicket.request.mapper.AbstractComponentMapper; > import org.apache.wicket.util.string.Strings; > > public class DetailMovedPageMapper extends AbstractComponentMapper { > > private static final boolean CASE_INSENSITIVE = false; > public static final String MOUNT_PATH = "ShowDetailPage"; > > public DetailMovedPageMapper() { > super(); > } > > @Override > public int getCompatibilityScore(Request request) { > String path = request.getUrl().getPath(); > if (Strings.startsWith(path, getMountPath(), CASE_INSENSITIVE)) { > String remainder = path.substring(getMountPath().length()); > if > (remainder.matches("(^\\.html$)|(^-ii\\d*\\.html$)|(^-ti\\d*-.*\\.html$)|(^-ti\\d*-ii\\d*-.*\\.html$)")) > { > return Integer.MAX_VALUE; > } > } > return -1; > } > > private String getMountPath() { > return MOUNT_PATH; > } > > @Override > public IRequestHandler mapRequest(Request request) { > return new BookmarkablePageRequestHandler(new > PageProvider(DetailMovedPage.class, extractPageParameters(request, 0, new > DetailMovedPageParametersEncoder()))); > } > > @Override > public Url mapHandler(IRequestHandler requestHandler) { > return null; > } > } > > But if i add it in Application.init (mount(new DetailMovedPageMapper());) > and call the homepage > nothing is displayed (blank page, no markup, no exception or log entry). > > What i try to do is simply map a call of > localhost:8080/ShowDetailPage-ti123-ii456.html > to DetailPageMoved(PageParameters[ti=123, ii=456]). > > Mike > >> Thanks Martin, >> >> the parameters are the appendixes to page name (-ti123-ki345-ii789). >> So i think i have to provide and encoder. >> >> Cheers >> Per >> >>> Yes, you need a custom IRequestMapper. You need to set it as root >>> mapper (see HttpsMapper and CryptoMapper examples). >>> You don't need custom IPageParametersEncoder unless you encode the >>> parameters in a special way. The url you showed below has no >>> parameters at all. >>> >>> On Sat, Sep 3, 2011 at 5:25 PM, Per Newgro<[email protected]> wrote: >>>> >>>> Hi, >>>> >>>> we have some urls like in following pattern >>>> http://domain.de/ShowTheme-ti123-ki345-ii789.html >>>> >>>> With wicket 1.4 we built a >>>> BookmarkablePageRequestTargetUrlCodingStrategy >>>> with matches(path) based on a pattern and encoding / decoding the url / >>>> parameters. >>>> >>>> Now i'm not sure how i have to migrate that to wicket 1.5. >>>> >>>> I think i have to provide a IRequestMapper. >>>> >>>> Is the getCompatibilityScore method the "equivalent" of matches(path)? >>>> Do i have to provide a custom IPageParametersEncoder to encode / decode >>>> my >>>> url / parameters? >>>> >>>> Thanks for clearification >>>> Per >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
