use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BaseWicketTester method invokeListener.
/**
* Simulates invoking an {@link IRequestListener} on a component. As opposed to the
* {@link #executeListener(Component)} method, current request/response objects will be used
*
* After the listener is invoked the page containing the component will be rendered
* (with an optional redirect - depending on {@link RenderStrategy}).
*
* @param component
* @param listener
*/
public void invokeListener(Component component, final Behavior behavior) {
Args.notNull(component, "component");
Args.notNull(behavior, "behavior");
// there are two ways to do this. RequestCycle could be forced to call the handler
// directly but constructing and parsing the URL increases the chance of triggering bugs
IRequestHandler handler = new ListenerRequestHandler(new PageAndComponentProvider(component.getPage(), component), component.getBehaviorId(behavior));
processRequest(handler);
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode8.
/**
*/
@Test
public void decode8() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/i1/i2?15-5.ILinkListener-foo-bar&a=b&b=c");
context.setNextPageRenderCount(5);
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(ListenerRequestHandler.class));
ListenerRequestHandler h = (ListenerRequestHandler) handler;
IRequestablePage page = h.getPage();
assertEquals(page.getRenderCount(), 5);
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode5.
/**
*/
@Test
public void decode5() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "?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());
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BookmarkableMapperTest method decode6.
/**
*/
@Test
public void decode6() {
Url url = Url.parse("wicket/bookmarkable/" + PAGE_CLASS_NAME + "/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());
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class MountedMapperTest method decode7.
/**
*/
@Test
public void decode7() {
Url url = Url.parse("some/mount/path?param1=value1&15-.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());
}
Aggregations