Search in sources :

Example 1 with RequestSettingRequestHandler

use of org.apache.wicket.core.request.handler.RequestSettingRequestHandler 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)

Example 2 with RequestSettingRequestHandler

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

the class CryptoMapper method mapRequest.

@Override
public IRequestHandler mapRequest(final Request request) {
    Url url = decryptUrl(request, request.getUrl());
    if (url == null) {
        return null;
    }
    Request decryptedRequest = request.cloneWithUrl(url);
    IRequestHandler handler = wrappedMapper.mapRequest(decryptedRequest);
    if (handler != null) {
        handler = new RequestSettingRequestHandler(decryptedRequest, handler);
    }
    return handler;
}
Also used : RequestSettingRequestHandler(org.apache.wicket.core.request.handler.RequestSettingRequestHandler) IRequestHandler(org.apache.wicket.request.IRequestHandler) Request(org.apache.wicket.request.Request) Url(org.apache.wicket.request.Url)

Aggregations

RequestSettingRequestHandler (org.apache.wicket.core.request.handler.RequestSettingRequestHandler)2 IRequestHandler (org.apache.wicket.request.IRequestHandler)2 Request (org.apache.wicket.request.Request)2 Url (org.apache.wicket.request.Url)2 MockPage (org.apache.wicket.MockPage)1 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)1 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)1 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)1 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)1 Test (org.junit.Test)1