use of org.apache.wicket.request.mapper.info.PageInfo in project wicket by apache.
the class AbstractBookmarkableMapper method processListener.
/**
* Creates a {@code IRequestHandler} that notifies an {@link IRequestListener}.
*
* @param pageComponentInfo
* @param pageClass
* @param pageParameters
* @return a {@code IRequestHandler} that notifies an {@link IRequestListener}.
*/
protected IRequestHandler processListener(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) {
PageInfo pageInfo = pageComponentInfo.getPageInfo();
ComponentInfo componentInfo = pageComponentInfo.getComponentInfo();
Integer renderCount = null;
if (componentInfo != null) {
renderCount = componentInfo.getRenderCount();
}
PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(), pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
provider.setPageSource(getContext());
checkExpiration(provider, pageInfo);
return new ListenerRequestHandler(provider, componentInfo.getBehaviorId());
}
use of org.apache.wicket.request.mapper.info.PageInfo 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;
}
use of org.apache.wicket.request.mapper.info.PageInfo in project wicket by apache.
the class AbstractBookmarkableMapperTest method itFailsToProcessAnExpiredPageIfShouldNotRecreateMountedPagesAfterExpiry.
/**
* <a href="https://issues.apache.org/jira/browse/WICKET-4932">WICKET-4932</a>
*/
@Test(expected = PageExpiredException.class)
public void itFailsToProcessAnExpiredPageIfShouldNotRecreateMountedPagesAfterExpiry() {
tester.getApplication().getPageSettings().setRecreateBookmarkablePagesAfterExpiry(false);
AbstractBookmarkableMapperStub mapper = new AbstractBookmarkableMapperStub();
mapper.processHybrid(new PageInfo(EXPIRED_ID), MockPage.class, null, NOT_RENDERED_COUNT);
Assert.fail("it shouldn't process expired pages if the app was flagged to not recreated mounted pages after expiry");
}
use of org.apache.wicket.request.mapper.info.PageInfo in project wicket by apache.
the class MountedMapper method mapHandler.
@Override
public Url mapHandler(IRequestHandler requestHandler) {
Url url = super.mapHandler(requestHandler);
if (url == null && requestHandler instanceof ListenerRequestHandler && getRecreateMountedPagesAfterExpiry()) {
ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
IRequestablePage page = handler.getPage();
if (checkPageInstance(page)) {
Integer renderCount = null;
if (handler.includeRenderCount()) {
renderCount = page.getRenderCount();
}
String componentPath = handler.getComponentPath();
PageInfo pageInfo = getPageInfo(handler);
ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
PageComponentInfo pageComponentInfo = new PageComponentInfo(pageInfo, componentInfo);
PageParameters parameters = newPageParameters();
parameters.mergeWith(page.getPageParameters());
UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), parameters.mergeWith(handler.getPageParameters()));
url = buildUrl(urlInfo);
}
}
return url;
}
use of org.apache.wicket.request.mapper.info.PageInfo 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;
}
}
Aggregations