/** * @see * org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper#parseRequest(org.apache.wicket.request.Request) */ @Override protected UrlInfo parseRequest(Request request) { Url url = request.getUrl(); if (url.getSegments().size() >= 1) { // try to extract page and component information from URL PageComponentInfo info = getPageComponentInfo(url); // load the page class String className = url.getSegments().get(0); if (isValidClassName(className) == false) { return null; } className = transformFromUrl(className); String fullyQualifiedClassName = packageName.getName() + '.' + className; Class<? extends IRequestablePage> pageClass = getPageClass(fullyQualifiedClassName); if (pageClass != null && Modifier.isAbstract(pageClass.getModifiers()) == false && IRequestablePage.class.isAssignableFrom(pageClass)) { // extract the PageParameters from URL if there are any PageParameters pageParameters = extractPageParameters(request, 1, pageParametersEncoder); return new UrlInfo(info, pageClass, pageParameters); } } return null; }
/** @see org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper#buildUrl(UrlInfo) */ @Override protected Url buildUrl(UrlInfo info) { Class<? extends IRequestablePage> pageClass = info.getPageClass(); PackageName pageClassPackageName = PackageName.forClass(pageClass); if (pageClassPackageName.equals(packageName)) { Url url = new Url(); String fullyQualifiedClassName = pageClass.getName(); String packageRelativeClassName = fullyQualifiedClassName; int packageNameLength = packageName.getName().length(); if (packageNameLength > 0) { packageRelativeClassName = fullyQualifiedClassName.substring(packageNameLength + 1); } packageRelativeClassName = transformForUrl(packageRelativeClassName); url.getSegments().add(packageRelativeClassName); encodePageComponentInfo(url, info.getPageComponentInfo()); return encodePageParameters(url, info.getPageParameters(), pageParametersEncoder); } return null; }