use of org.apache.wicket.request.IRequestHandlerDelegate in project wicket by apache.
the class AbstractBookmarkableMapper method mapHandler.
@Override
public Url mapHandler(IRequestHandler requestHandler) {
// eliminate the need for IRequestHandlerDelegate
while (requestHandler instanceof IRequestHandlerDelegate) {
requestHandler = ((IRequestHandlerDelegate) requestHandler).getDelegateHandler();
}
if (requestHandler instanceof BookmarkablePageRequestHandler) {
// simple bookmarkable URL with no page instance information
BookmarkablePageRequestHandler handler = (BookmarkablePageRequestHandler) requestHandler;
if (!checkPageClass(handler.getPageClass())) {
return null;
}
PageInfo info = new PageInfo();
UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null), handler.getPageClass(), handler.getPageParameters());
return buildUrl(urlInfo);
} else if (requestHandler instanceof RenderPageRequestHandler) {
// possibly hybrid URL - bookmarkable URL with page instance information
// but only allowed if the page was created by bookmarkable URL
RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
if (!checkPageClass(handler.getPageClass())) {
return null;
}
if (handler.getPageProvider().isNewPageInstance()) {
// no existing page instance available, don't bother creating new page instance
PageInfo info = new PageInfo();
UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null), handler.getPageClass(), handler.getPageParameters());
return buildUrl(urlInfo);
}
IRequestablePage page = handler.getPage();
if (checkPageInstance(page) && (!pageMustHaveBeenCreatedBookmarkable() || page.wasCreatedBookmarkable())) {
PageInfo info = getPageInfo(handler);
PageComponentInfo pageComponentInfo = new PageComponentInfo(info, null);
UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), handler.getPageParameters());
return buildUrl(urlInfo);
} else {
return null;
}
} else if (requestHandler instanceof BookmarkableListenerRequestHandler) {
// request listener URL with page class information
BookmarkableListenerRequestHandler handler = (BookmarkableListenerRequestHandler) requestHandler;
Class<? extends IRequestablePage> pageClass = handler.getPageClass();
if (!checkPageClass(pageClass)) {
return null;
}
Integer renderCount = null;
if (handler.includeRenderCount()) {
renderCount = handler.getRenderCount();
}
PageInfo pageInfo = getPageInfo(handler);
ComponentInfo componentInfo = new ComponentInfo(renderCount, handler.getComponentPath(), handler.getBehaviorIndex());
PageParameters parameters = getRecreateMountedPagesAfterExpiry() ? new PageParameters(handler.getPage().getPageParameters()).mergeWith(handler.getPageParameters()) : handler.getPageParameters();
UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(pageInfo, componentInfo), pageClass, parameters);
return buildUrl(urlInfo);
}
return null;
}
Aggregations