Search in sources :

Example 81 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler in project wicket by apache.

the class PackageMapperTest 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(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?a=b&b=c", url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) BookmarkablePageRequestHandler(org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 82 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler in project wicket by apache.

the class PackageMapperTest method decodeAlias.

/**
 * https://issues.apache.org/jira/browse/WICKET-3941
 */
@Test
public void decodeAlias() {
    Url url = Url.parse(MOUNT_PATH + '/' + ALIAS + "?15");
    IRequestHandler handler = aliasEncoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(RenderPageRequestHandler.class));
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    checkPage(page, 15);
    assertEquals(PAGE_CLASS_NAME, page.getClass().getSimpleName());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 83 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler in project wicket by apache.

the class PackageMapperTest 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(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?15&a=b&b=c", url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 84 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler in project wicket by apache.

the class PageInstanceMapperTest method decode3.

/**
 */
@Test
public void decode3() {
    Url url = Url.parse("wicket/page?4--a-b-c");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ListenerRequestHandler.class));
    ListenerRequestHandler h = (ListenerRequestHandler) handler;
    checkPage(h.getPage(), 4);
    assertEquals(h.getComponent().getPageRelativePath(), "a:b:c");
    assertNull(h.getBehaviorIndex());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 85 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler in project wicket by apache.

the class PageInstanceMapperTest method decode7.

/**
 */
@Test
public void decode7() {
    Url url = Url.parse("wicket/page?4-6.5-a-b-c");
    context.setNextPageRenderCount(6);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ListenerRequestHandler.class));
    ListenerRequestHandler h = (ListenerRequestHandler) handler;
    assertEquals(6, h.getPage().getRenderCount());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

IRequestHandler (org.apache.wicket.request.IRequestHandler)188 Test (org.junit.Test)159 Url (org.apache.wicket.request.Url)138 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)65 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)47 PageProvider (org.apache.wicket.core.request.handler.PageProvider)45 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)36 IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)32 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)28 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)25 Request (org.apache.wicket.request.Request)25 MockPage (org.apache.wicket.MockPage)23 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)20 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)17 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)17 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)16 IPageRequestHandler (org.apache.wicket.core.request.handler.IPageRequestHandler)11 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)10 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)8 Page (org.apache.wicket.Page)6