Search in sources :

Example 21 with ListenerRequestHandler

use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.

the class MountedMapperTest method decode10.

/**
 */
@Test
public void decode10() {
    Url url = Url.parse("some/mount/path?15-5.4-foo-bar");
    context.setNextPageRenderCount(5);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(ListenerRequestHandler.class));
    ListenerRequestHandler h = (ListenerRequestHandler) handler;
    IRequestablePage page = h.getPage();
    assertEquals(5, page.getRenderCount());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 22 with ListenerRequestHandler

use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.

the class MountedMapperTest method decode5.

/**
 */
@Test
public void decode5() {
    Url url = Url.parse("some/mount/path?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());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 23 with ListenerRequestHandler

use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.

the class MountedMapperTest method decode6.

/**
 */
@Test
public void decode6() {
    Url url = Url.parse("some/mount/path/i1/i2?15--foo-bar&a=b&b=c");
    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());
    PageParameters p = page.getPageParameters();
    assertEquals(0, p.getIndexedCount());
    assertEquals(0, p.getNamedKeys().size());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 24 with ListenerRequestHandler

use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.

the class MountedMapperTest method encode7_1.

/**
 * https://issues.apache.org/jira/browse/WICKET-4014
 *
 * The difference with testEncode7 is that here ListenerRequestHandler is used instead
 * of BookmarkableListenerRequestHandler
 */
@Test
public void encode7_1() {
    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.setRenderCount(5);
    // shouldn't make any difference for ListenerRequestHandler,
    // as this explicitly says the url must be bookmarkable
    page.setCreatedBookmarkable(false);
    IRequestableComponent c = page.get("foo:bar");
    PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
    IRequestHandler handler = new ListenerRequestHandler(provider, 4);
    Url url = encoder.mapHandler(handler);
    assertEquals("some/mount/path/i1/i2?15-5.4-foo-bar&a=b&b=c", url.toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) IRequestHandler(org.apache.wicket.request.IRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 25 with ListenerRequestHandler

use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.

the class MountedMapperTest method encode6_1.

/**
 * https://issues.apache.org/jira/browse/WICKET-4014
 *
 * The difference with testEncode7 is that here ListenerRequestHandler is used instead
 * of BookmarkableListenerRequestHandler
 */
@Test
public void encode6_1() {
    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);
    // WICKET-4038
    page.getPageParameters().add(WebRequest.PARAM_AJAX, "true", INamedParameters.Type.QUERY_STRING);
    page.getPageParameters().add(WebRequest.PARAM_AJAX_BASE_URL, "some/base/url", INamedParameters.Type.QUERY_STRING);
    page.setRenderCount(4);
    // shouldn't make any difference for ListenerRequestHandler,
    // as this explicitly says the url must be bookmarkable
    page.setCreatedBookmarkable(false);
    IRequestableComponent c = page.get("foo:bar");
    PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
    IRequestHandler handler = new ListenerRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals("some/mount/path/i1/i2?15-4.-foo-bar&a=b&b=c", url.toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) IRequestHandler(org.apache.wicket.request.IRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)30 IRequestHandler (org.apache.wicket.request.IRequestHandler)25 Url (org.apache.wicket.request.Url)25 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)22 Test (org.junit.Test)21 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)16 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)12 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)5 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)5 MockPage (org.apache.wicket.MockPage)4 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)4 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)4 PageInfo (org.apache.wicket.request.mapper.info.PageInfo)3 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)2 Page (org.apache.wicket.Page)1 IPageAndComponentProvider (org.apache.wicket.core.request.handler.IPageAndComponentProvider)1 PageProvider (org.apache.wicket.core.request.handler.PageProvider)1 RequestSettingRequestHandler (org.apache.wicket.core.request.handler.RequestSettingRequestHandler)1 WebPage (org.apache.wicket.markup.html.WebPage)1 Request (org.apache.wicket.request.Request)1