Search in sources :

Example 1 with PageAndComponentProvider

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

the class BehaviorRequestTest method urlForBehavior.

private String urlForBehavior(Behavior behaviorUnderTest) {
    final int index = page.container.getBehaviorId(behaviorUnderTest);
    final IPageAndComponentProvider provider = new PageAndComponentProvider(page, page.container);
    final IRequestHandler handler = new ListenerRequestHandler(provider, index);
    return tester.urlFor(handler).toString();
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) IPageAndComponentProvider(org.apache.wicket.core.request.handler.IPageAndComponentProvider) IPageAndComponentProvider(org.apache.wicket.core.request.handler.IPageAndComponentProvider) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler)

Example 2 with PageAndComponentProvider

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

the class AbstractBookmarkableMapper method processListener.

/**
 * Creates a {@code IRequestHandler} that notifies an {@link IRequestListener}.
 *
 * @param pageComponentInfo
 * @param pageClass
 * @param pageParameters
 * @return a {@code IRequestHandler} that notifies an {@link IRequestListener}.
 */
protected IRequestHandler processListener(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) {
    PageInfo pageInfo = pageComponentInfo.getPageInfo();
    ComponentInfo componentInfo = pageComponentInfo.getComponentInfo();
    Integer renderCount = null;
    if (componentInfo != null) {
        renderCount = componentInfo.getRenderCount();
    }
    PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(), pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
    provider.setPageSource(getContext());
    checkExpiration(provider, pageInfo);
    return new ListenerRequestHandler(provider, componentInfo.getBehaviorId());
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)

Example 3 with PageAndComponentProvider

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

the class BookmarkableMapperTest method encode7.

/**
 */
@Test
public void encode7() {
    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);
    // shouldn't make any difference for BookmarkableListenerRequestHandler,
    // 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 BookmarkableListenerRequestHandler(provider, 4);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15-0.4-foo-bar&a=b&b=c", url.toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) IRequestHandler(org.apache.wicket.request.IRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 4 with PageAndComponentProvider

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

the class CryptoMapperTest method homePageForceEncryptionOfRequestListener.

/**
 * Tests that we do not allow unencrypted URLs to IRequestListeners on the home page, like: ?0-0.ILinkListener-link
 */
@Test
public void homePageForceEncryptionOfRequestListener() {
    PageAndComponentProvider provider = new PageAndComponentProvider(tester.getApplication().getHomePage(), "link");
    IRequestHandler requestHandler = new BookmarkableListenerRequestHandler(provider);
    Url plainUrl = mapper.getDelegateMapper().mapHandler(requestHandler);
    assertTrue("Plain URL for home page has segments: " + plainUrl.toString(), plainUrl.getSegments().isEmpty());
    assertNull(mapper.mapRequest(getRequest(plainUrl)));
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 5 with PageAndComponentProvider

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

the class CryptoMapperTest method additionalParameters.

/**
 * Additional parameters, WICKET-4923
 */
@Test
public void additionalParameters() {
    MockPage page = new MockPage();
    IRequestableComponent c = page.get("foo:bar");
    PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
    IRequestHandler handler = new ListenerRequestHandler(provider);
    Url url = mapper.mapHandler(handler);
    url.addQueryParameter("q", "foo");
    Request request = getRequest(url);
    IRequestHandler requestHandler = mapper.mapRequest(request);
    assertThat(requestHandler, instanceOf(RequestSettingRequestHandler.class));
    assertEquals("foo", ((RequestSettingRequestHandler) requestHandler).getRequest().getUrl().getQueryParameterValue("q").toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) RequestSettingRequestHandler(org.apache.wicket.core.request.handler.RequestSettingRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) Request(org.apache.wicket.request.Request) 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

PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)20 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)17 IRequestHandler (org.apache.wicket.request.IRequestHandler)17 Url (org.apache.wicket.request.Url)15 Test (org.junit.Test)13 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)12 MockPage (org.apache.wicket.MockPage)10 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)10 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)3 ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)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 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)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 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)1 PageInfo (org.apache.wicket.request.mapper.info.PageInfo)1