use of org.apache.wicket.core.request.handler.RenderPageRequestHandler 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.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class AbstractBookmarkableMapper method processHybrid.
/**
* Creates a {@code IRequestHandler} that processes a hybrid request. When the page identified
* by {@code pageInfo} was not available, the request should be treated as a bookmarkable
* request.
*
* @param pageInfo
* @param pageClass
* @param pageParameters
* @param renderCount
* @return a {@code IRequestHandler} capable of processing the hybrid request.
*/
protected IRequestHandler processHybrid(PageInfo pageInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount) {
PageProvider provider = new PageProvider(pageInfo.getPageId(), pageClass, pageParameters, renderCount);
provider.setPageSource(getContext());
checkExpiration(provider, pageInfo);
/**
* https://issues.apache.org/jira/browse/WICKET-5734
*/
PageParameters constructionPageParameters = provider.hasPageInstance() ? provider.getPageInstance().getPageParameters() : new PageParameters();
if (PageParameters.equals(constructionPageParameters, pageParameters) == false) {
// when the resolved page by id has been created
return new RenderPageRequestHandler(new PageProvider(pageClass, pageParameters));
}
return new RenderPageRequestHandler(provider);
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method encode4.
/**
*/
@Test
public void encode4() {
MockPage page = new MockPage(15);
page.getPageParameters().set(0, "i1");
page.getPageParameters().set(1, "i2");
page.getPageParameters().set("a", "b", INamedParameters.Type.QUERY_STRING);
page.getPageParameters().set("b", "c", INamedParameters.Type.QUERY_STRING);
page.setCreatedBookmarkable(true);
IPageProvider provider = new PageProvider(page);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode1.
/**
*/
@Test
public void decode1() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME);
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(PAGE_CLASS_NAME, page.getClass().getName());
assertEquals(0, page.getPageParameters().getIndexedCount());
assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode2.
/**
*/
@Test
public void decode2() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/indexed1?a=b&b=c");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(PAGE_CLASS_NAME, page.getClass().getName());
PageParameters p = page.getPageParameters();
assertEquals(1, p.getIndexedCount());
assertEquals("indexed1", p.get(0).toString());
assertEquals(2, p.getNamedKeys().size());
assertEquals("b", p.get("a").toString());
assertEquals("c", p.get("b").toString());
}
Aggregations