use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class BookmarkableMapperTest method decode7.
/**
*/
@Test
public void decode7() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "?15-ILinkListener.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 BookmarkableMapperTest method decode13.
/**
* WICKET-5071
*
* Decodes a request to
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getBookmarkableIdentifier()}
* /com.example.MyPage when the current base url is
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getNamespace()} /
* {@link org.apache.wicket.core.request.mapper.IMapperContext#getPageIdentifier()}
*/
@Test
public void decode13() {
final Url url = Url.parse(context.getBookmarkableIdentifier() + "/" + PAGE_CLASS_NAME);
Request request = new Request() {
@Override
public Url getUrl() {
return url;
}
@Override
public Locale getLocale() {
return null;
}
@Override
public Charset getCharset() {
return Charset.forName("UTF-8");
}
@Override
public Url getClientUrl() {
StringBuilder url = new StringBuilder();
url.append(context.getBookmarkableIdentifier()).append('/').append(PAGE_CLASS_NAME);
return Url.parse(url.toString());
}
@Override
public Object getContainerRequest() {
return null;
}
};
IRequestHandler handler = encoder.mapRequest(request);
assertNotNull("A handler should be resolved for relative url to a bookmarkable page url!", handler);
IRequestablePage page = ((IPageRequestHandler) handler).getPage();
assertEquals(page.getClass().getName(), PAGE_CLASS_NAME);
}
use of org.apache.wicket.request.component.IRequestablePage 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());
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class BookmarkableMapperTest method decode3.
/**
* 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).
*
* The request that the encoder does also has no parameters (neither in the path
* nor in the query string) so the resolved page is assumed to be valid.
*/
@Test
public void decode3() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "?15");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
checkPage(page, 15);
}
use of org.apache.wicket.request.component.IRequestablePage in project wicket by apache.
the class MountedMapperTest method placeholderDecodeWithIndexedParameters.
/**
*/
@Test
public void placeholderDecodeWithIndexedParameters() {
Url url = Url.parse("some/p1/path/p2/p3/p4");
IRequestHandler handler = placeholderEncoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals(2, page.getPageParameters().getIndexedCount());
assertTrue(page.getPageParameters().getNamedKeys().size() == 2);
assertEquals("p1", page.getPageParameters().get("param1").toString());
assertEquals("p2", page.getPageParameters().get("param2").toString());
assertEquals("p3", page.getPageParameters().get(0).toString());
assertEquals("p4", page.getPageParameters().get(1).toString());
}
Aggregations