use of org.apache.wicket.request.mapper.info.PageComponentInfo in project wicket by apache.
the class PageInstanceMapper method mapRequest.
/**
* @see org.apache.wicket.request.IRequestMapper#mapRequest(org.apache.wicket.request.Request)
*/
@Override
public IRequestHandler mapRequest(Request request) {
if (matches(request)) {
Url url = request.getUrl();
PageComponentInfo info = getPageComponentInfo(url);
if (info != null && info.getPageInfo().getPageId() != null) {
Integer renderCount = info.getComponentInfo() != null ? info.getComponentInfo().getRenderCount() : null;
if (info.getComponentInfo() == null) {
PageProvider provider = new PageProvider(info.getPageInfo().getPageId(), renderCount);
provider.setPageSource(getContext());
// render page
return new RenderPageRequestHandler(provider);
} else {
ComponentInfo componentInfo = info.getComponentInfo();
PageAndComponentProvider provider = new PageAndComponentProvider(info.getPageInfo().getPageId(), renderCount, componentInfo.getComponentPath());
provider.setPageSource(getContext());
return new ListenerRequestHandler(provider, componentInfo.getBehaviorId());
}
}
}
return null;
}
use of org.apache.wicket.request.mapper.info.PageComponentInfo in project wicket by apache.
the class PackageMapper method parseRequest.
@Override
protected UrlInfo parseRequest(Request request) {
Url url = request.getUrl();
if (urlStartsWithMountedSegments(url)) {
// try to extract page and component information from URL
PageComponentInfo info = getPageComponentInfo(url);
final List<String> segments = url.getSegments();
if (segments.size() <= mountSegments.length) {
return null;
}
// load the page class
String name = segments.get(mountSegments.length);
if (Strings.isEmpty(name)) {
return null;
}
String className = cleanClassName(name);
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
Url urlWithoutPageSegment = new Url(url);
urlWithoutPageSegment.getSegments().remove(mountSegments.length);
Request requestWithoutPageSegment = request.cloneWithUrl(urlWithoutPageSegment);
PageParameters pageParameters = extractPageParameters(requestWithoutPageSegment, urlWithoutPageSegment);
return new UrlInfo(info, pageClass, pageParameters);
}
}
return null;
}
use of org.apache.wicket.request.mapper.info.PageComponentInfo in project wicket by apache.
the class PageInstanceMapper method mapHandler.
/**
* @see org.apache.wicket.request.IRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
*/
@Override
public Url mapHandler(IRequestHandler requestHandler) {
PageComponentInfo info = null;
if (requestHandler instanceof RenderPageRequestHandler) {
IRequestablePage page = ((RenderPageRequestHandler) requestHandler).getPage();
PageInfo i = new PageInfo(page.getPageId());
info = new PageComponentInfo(i, null);
} else if (requestHandler instanceof ListenerRequestHandler) {
ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
IRequestablePage page = handler.getPage();
String componentPath = handler.getComponentPath();
Integer renderCount = null;
if (handler.includeRenderCount()) {
renderCount = page.getRenderCount();
}
PageInfo pageInfo = new PageInfo(page.getPageId());
ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
info = new PageComponentInfo(pageInfo, componentInfo);
}
if (info != null) {
Url url = new Url();
url.getSegments().add(getContext().getNamespace());
url.getSegments().add(getContext().getPageIdentifier());
encodePageComponentInfo(url, info);
return url;
} else {
return null;
}
}
use of org.apache.wicket.request.mapper.info.PageComponentInfo in project wicket by apache.
the class AbstractBookmarkableMapper method mapRequest.
@Override
public IRequestHandler mapRequest(Request request) {
UrlInfo urlInfo = parseRequest(request);
if (urlInfo != null) {
PageComponentInfo info = urlInfo.getPageComponentInfo();
Class<? extends IRequestablePage> pageClass = urlInfo.getPageClass();
PageParameters pageParameters = urlInfo.getPageParameters();
if (info == null) {
// then this is a simple bookmarkable URL
return processBookmarkable(pageClass, pageParameters);
} else if (info.getPageInfo().getPageId() != null && info.getComponentInfo() == null) {
// instance
return processHybrid(info.getPageInfo(), pageClass, pageParameters, null);
} else if (info.getComponentInfo() != null) {
// with both page instance and component this is a request listener URL
return processListener(info, pageClass, pageParameters);
} else if (info.getPageInfo().getPageId() == null) {
return processBookmarkable(pageClass, pageParameters);
}
}
return null;
}
Aggregations