Search in sources :

Example 76 with IRequestHandler

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

the class PackageMapperTest method encodeInnerClass.

/**
 * https://issues.apache.org/jira/browse/WICKET-3838
 */
@Test
public void encodeInnerClass() {
    InnerPage page = new OuterPage.InnerPage();
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new BookmarkablePageRequestHandler(provider);
    Url url = innerClassEncoder.mapHandler(handler);
    assertEquals(MOUNT_PATH + '/' + "PackageMapperTest$OuterPage$InnerPage", 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) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) InnerPage(org.apache.wicket.core.request.mapper.PackageMapperTest.OuterPage.InnerPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 77 with IRequestHandler

use of org.apache.wicket.request.IRequestHandler 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());
}
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) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 78 with IRequestHandler

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

the class PackageMapperTest method decode1.

/**
 */
@Test
public void decode1() {
    Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME);
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertThat(handler, instanceOf(RenderPageRequestHandler.class));
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    assertEquals(PAGE_CLASS_NAME, page.getClass().getSimpleName());
    assertEquals(0, page.getPageParameters().getIndexedCount());
    assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
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 79 with IRequestHandler

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

the class PackageMapperTest 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(MOUNT_PATH + '/' + PAGE_CLASS_NAME, 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 80 with IRequestHandler

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

the class PackageMapperTest method decodePageClassWithPathParameters.

/**
 * https://issues.apache.org/jira/browse/WICKET-5500
 */
@Test
public void decodePageClassWithPathParameters() {
    Url url = Url.parse(MOUNT_PATH + '/' + PAGE_CLASS_NAME + ";something=else");
    IRequestHandler handler = encoder.mapRequest(getRequest(url));
    assertTrue(handler instanceof RenderPageRequestHandler);
    IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
    assertEquals(PAGE_CLASS_NAME, page.getClass().getSimpleName());
    assertEquals(0, page.getPageParameters().getIndexedCount());
    assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
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)

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