Search in sources :

Example 11 with IRequestableComponent

use of org.apache.wicket.request.component.IRequestableComponent in project wicket by apache.

the class PackageMapperTest method encode6.

/**
 */
@Test
public void encode6() {
    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);
    Url url = encoder.mapHandler(handler);
    assertEquals(MOUNT_PATH + '/' + PAGE_CLASS_NAME + "/i1/i2?15-0.-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 12 with IRequestableComponent

use of org.apache.wicket.request.component.IRequestableComponent in project wicket by apache.

the class PackageMapperTest 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(MOUNT_PATH + '/' + 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 13 with IRequestableComponent

use of org.apache.wicket.request.component.IRequestableComponent in project wicket by apache.

the class PageInstanceMapperTest method encode2.

/**
 */
@Test
public void encode2() {
    MockPage page = new MockPage(15);
    page.setRenderCount(5);
    IRequestableComponent c = page.get("a:b:c");
    PageAndComponentProvider provider = new PageAndComponentProvider(page, c);
    IRequestHandler handler = new ListenerRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/page?15-5.-a-b-c", url.toString());
}
Also used : IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent) IRequestHandler(org.apache.wicket.request.IRequestHandler) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 14 with IRequestableComponent

use of org.apache.wicket.request.component.IRequestableComponent in project wicket by apache.

the class RequestListenerInterface method invoke.

/**
 * Invokes a given interface on a component.
 *
 * @param rcomponent
 *            The component
 *
 * @throws ListenerInvocationNotAllowedException
 *             when listener invocation attempted on a component that does not allow it
 */
public final void invoke(final IRequestableComponent rcomponent) {
    // we are in Wicket core land
    final Component component = (Component) rcomponent;
    if (!component.canCallListener()) {
        // just return so that we have a silent fail and just re-render the
        // page
        log.info("component not enabled or visible; ignoring call. Component: " + component);
        throw new ListenerInvocationNotAllowedException(component, null, "Component rejected interface invocation");
    }
    internalInvoke(component, component);
}
Also used : ListenerInvocationNotAllowedException(org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException) IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent)

Example 15 with IRequestableComponent

use of org.apache.wicket.request.component.IRequestableComponent in project wicket by apache.

the class RequestListenerInterface method invoke.

/**
 * Invokes a given interface on a component's behavior.
 *
 * @param rcomponent
 *            The component
 * @param behavior
 * @throws ListenerInvocationNotAllowedException
 *             when listener invocation attempted on a component that does not allow it
 */
public final void invoke(final IRequestableComponent rcomponent, final Behavior behavior) {
    // we are in Wicket core land
    final Component component = (Component) rcomponent;
    if (!behavior.canCallListener(component)) {
        log.warn("behavior not enabled; ignore call. Behavior {} at component {}", behavior, component);
        throw new ListenerInvocationNotAllowedException(component, behavior, "Behavior rejected interface invocation. ");
    }
    internalInvoke(component, behavior);
}
Also used : ListenerInvocationNotAllowedException(org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException) IRequestableComponent(org.apache.wicket.request.component.IRequestableComponent)

Aggregations

IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)15 MockPage (org.apache.wicket.MockPage)10 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)10 IRequestHandler (org.apache.wicket.request.IRequestHandler)10 Url (org.apache.wicket.request.Url)10 Test (org.junit.Test)10 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)9 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)4 Component (org.apache.wicket.Component)2 ListenerInvocationNotAllowedException (org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException)2 Page (org.apache.wicket.Page)1 RedirectPolicy (org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy)1 RequestSettingRequestHandler (org.apache.wicket.core.request.handler.RequestSettingRequestHandler)1 Request (org.apache.wicket.request.Request)1 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)1 WebRequest (org.apache.wicket.request.http.WebRequest)1