use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method placeholderDecode2.
/**
*/
@Test
public void placeholderDecode2() {
Url url = Url.parse("some/p1/path/p2/indexed1?a=b&b=c");
IRequestHandler handler = placeholderEncoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
PageParameters p = page.getPageParameters();
assertEquals(1, p.getIndexedCount());
assertEquals("indexed1", p.get(0).toString());
assertEquals(4, p.getNamedKeys().size());
assertEquals("b", p.get("a").toString());
assertEquals("c", p.get("b").toString());
assertEquals("p1", page.getPageParameters().get("param1").toString());
assertEquals("p2", page.getPageParameters().get("param2").toString());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method decode4.
/**
* The tests resolves pages by id as if they were existed in the page store.
* These pages have no page parameters (i.e. page.getPageParameters() == null).
*
* Since Wicket 7.0.0 (WICKET-4441) if a new request to hybrid url
* (a url with both mount path and pageId) has different page parameters
* than the resolved page then a new page instance with the new parameters
* is created.
* This way if a user manipulates manually the product id in url like:
* /products/23?3
* to
* /products/24?3
* then Wicket will create a new page that will show product=24
*/
@Test
public void decode4() {
Url url = Url.parse("some/mount/path/i1/i2?15&a=b&b=c");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler h = (RenderPageRequestHandler) handler;
((PageProvider) h.getPageProvider()).setPageSource(context);
IRequestablePage page = h.getPage();
checkPage(page, 1);
PageParameters p = page.getPageParameters();
assertEquals(2, p.getIndexedCount());
assertEquals(2, p.getNamedKeys().size());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class PackageMapperTest method decode5.
/**
*/
@Test
public void decode5() {
Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "?15--foo-bar");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(ListenerRequestHandler.class));
ListenerRequestHandler h = (ListenerRequestHandler) handler;
IRequestablePage page = h.getPage();
checkPage(page, 15);
assertEquals("foo:bar", h.getComponent().getPageRelativePath());
assertNull(h.getBehaviorIndex());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class PackageMapperTest method decode7.
/**
*/
@Test
public void decode7() {
Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "?15-.4-foo-bar");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(ListenerRequestHandler.class));
ListenerRequestHandler h = (ListenerRequestHandler) handler;
IRequestablePage page = h.getPage();
checkPage(page, 15);
assertEquals("foo:bar", h.getComponent().getPageRelativePath());
assertEquals((Object) 4, h.getBehaviorIndex());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class PackageMapperTest method decode4.
/**
* The tests resolves pages by id as if they were existed in the page store.
* These pages have no page parameters (i.e. page.getPageParameters() == null).
*
* Since Wicket 7.0.0 (WICKET-4441) if a new request to hybrid url
* (a url with both mount path and pageId) has different page parameters
* than the resolved page then a new page instance with the new parameters
* is created.
* This way if a user manipulates manually the product id in url like:
* /mount/path/Products/23?3
* to
* /mount/path/Products/24?3
* then Wicket will create a new page that will show product=24
*/
@Test
public void decode4() {
Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler h = (RenderPageRequestHandler) handler;
((PageProvider) h.getPageProvider()).setPageSource(context);
IRequestablePage page = h.getPage();
checkPage(page, 1);
PageParameters p = page.getPageParameters();
assertEquals(2, p.getIndexedCount());
assertEquals(2, p.getNamedKeys().size());
}
Aggregations