use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode5.
/**
*/
@Test
public void encode5() {
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(false);
IPageProvider provider = new PageProvider(page);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
// never allow bookmarkable render url for page that has not been
// created by bookmarkable
// URL
assertNull(url);
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode1.
/**
*/
@Test
public void encode1() {
PageProvider provider = new PageProvider(MockPage.class, new PageParameters());
provider.setPageSource(context);
IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME, url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode2.
/**
*/
@Test
public void encode2() {
PageParameters parameters = new PageParameters();
parameters.set(0, "i1");
parameters.set(1, "i2");
parameters.set("a", "b", INamedParameters.Type.QUERY_STRING);
parameters.set("b", "c", INamedParameters.Type.QUERY_STRING);
PageProvider provider = new PageProvider(MockPage.class, parameters);
provider.setPageSource(context);
IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?a=b&b=c", url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest method encode8.
/**
*/
@Test
public void encode8() {
MockPage page = new MockPage(15);
page.setBookmarkable(true);
page.setCreatedBookmarkable(true);
page.setPageStateless(true);
IPageProvider provider = new PageProvider(page);
IRequestHandler handler = new RenderPageRequestHandler(provider);
Url url = encoder.mapHandler(handler);
assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME, url.toString());
}
use of org.apache.wicket.core.request.handler.PageProvider in project wicket by apache.
the class BookmarkableMapperTest 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:
* /wicket/bookmarkable/my.Product?3&id=23
* to
* /wicket/bookmarkable/my.Product?3&id=24
* then Wicket will create a new page that will show product=24
*/
@Test
public void decode4() {
Url url = Url.parse("wicket/bookmarkable/" + 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