use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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();
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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());
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode7.
/**
*/
@Test
public void decode7() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "?15-ILinkListener.4-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());
assertEquals((Object) 4, h.getBehaviorIndex());
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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());
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class CryptoMapperTest method mountedPageRequestListenerParameter.
/**
* Tests that PageComponentInfo parameters are encrypted on Mounted pages
*/
@Test
public void mountedPageRequestListenerParameter() {
final String componentPath = "link";
PageAndComponentProvider provider = new PageAndComponentProvider(Page1.class, componentPath);
IRequestHandler requestHandler = new ListenerRequestHandler(provider);
Url plainUrl = mapper.getDelegateMapper().mapHandler(requestHandler);
assertTrue(plainUrl.toString().startsWith(MOUNTED_URL));
/*
* Do not allow unencrypted request listener urls to mounted pages.
*/
assertNull(mapper.mapRequest(getRequest(plainUrl)));
/*
* Test encryption of request listener parameter.
*/
Url encryptedUrl = mapper.mapHandler(requestHandler);
assertEquals(Url.parse(MOUNTED_URL).getSegments(), encryptedUrl.getSegments());
assertTrue(encryptedUrl.getQueryParameters().size() > 0);
for (Url.QueryParameter qp : encryptedUrl.getQueryParameters()) {
if (Strings.isEmpty(qp.getValue())) {
PageComponentInfo pci = PageComponentInfo.parse(qp.getName());
assertNull("PageComponentInfo query parameter not encrypted", pci);
}
}
requestHandler = mapper.mapRequest(getRequest(encryptedUrl));
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(ListenerRequestHandler.class));
ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
assertEquals(componentPath, handler.getComponentPath());
assertEquals(Page1.class, handler.getPageClass());
/*
* We anticipate that sometimes multiple cryptomappers will be used. It should still work in these situations.
*/
requestHandler = new CryptoMapper(mapper, tester.getApplication()).mapRequest(getRequest(encryptedUrl));
assertNotNull(requestHandler);
requestHandler = unwrapRequestHandlerDelegate(requestHandler);
assertThat(requestHandler, instanceOf(ListenerRequestHandler.class));
handler = (ListenerRequestHandler) requestHandler;
assertEquals(componentPath, handler.getComponentPath());
assertEquals(Page1.class, handler.getPageClass());
}
Aggregations