Search in sources :

Example 1 with IPageProvider

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

the class WicketTesterTest method setQueryParameterWhenRequestHasAnQueryUrl.

/**
 * Asserting that parameters set in request get processed, even if the request URL already has
 * query parameters
 */
@Test
public void setQueryParameterWhenRequestHasAnQueryUrl() {
    PageParameters parameters = new PageParameters();
    parameters.set("q_1", "q_1_value");
    IPageProvider testPageProvider = new PageProvider(MockPageParametersAware.class, parameters);
    IRequestHandler pageRequestHandler = new BookmarkablePageRequestHandler(testPageProvider);
    Url url = tester.getApplication().getRootRequestMapper().mapHandler(pageRequestHandler);
    tester.getRequest().setParameter("q_2", "q_2_value");
    tester.getRequest().setUrl(url);
    tester.processRequest();
    MockPageParametersAware page = (MockPageParametersAware) tester.getLastRenderedPage();
    assertEquals("q_1_value", page.getLastQueryParameters().getParameterValue("q_1").toString());
    assertEquals("q_2_value", page.getLastQueryParameters().getParameterValue("q_2").toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) BookmarkablePageRequestHandler(org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler) MockPageParametersAware(org.apache.wicket.MockPageParametersAware) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 2 with IPageProvider

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

the class RequestCycle method setResponsePage.

/**
 * Convenience method for setting next page to be rendered.
 *
 * @param pageClass
 *              The class of the page to render
 * @param parameters
 *              The query parameters for the page to be rendered
 * @param redirectPolicy
 *              The policy to use when deciding whether to redirect or not
 */
public void setResponsePage(Class<? extends IRequestablePage> pageClass, PageParameters parameters, RenderPageRequestHandler.RedirectPolicy redirectPolicy) {
    IPageProvider provider = new PageProvider(pageClass, parameters);
    scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(provider, redirectPolicy));
}
Also used : RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider)

Example 3 with IPageProvider

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

the class BookmarkableMapperTest method encode5.

/**
 */
@Test
public void encode5() {
    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);
    page.setCreatedBookmarkable(false);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    // never allow bookmarkable render url for page that has not been
    // created by bookmarkable
    // URL
    assertNull(url);
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 4 with IPageProvider

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

the class BookmarkableMapperTest method encode8.

/**
 */
@Test
public void encode8() {
    MockPage page = new MockPage(15);
    page.setBookmarkable(true);
    page.setCreatedBookmarkable(true);
    page.setPageStateless(true);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    assertEquals("wicket/bookmarkable/" + PAGE_CLASS_NAME, url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Example 5 with IPageProvider

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

the class MountedMapperTest method encode5.

/**
 */
@Test
public void encode5() {
    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);
    page.setCreatedBookmarkable(false);
    IPageProvider provider = new PageProvider(page);
    IRequestHandler handler = new RenderPageRequestHandler(provider);
    Url url = encoder.mapHandler(handler);
    // mounted pages must render mounted url even for page that has not been
    // created by
    // bookmarkable
    // URL
    assertEquals("some/mount/path/i1/i2?15&a=b&b=c", url.toString());
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) MockPage(org.apache.wicket.MockPage) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

IPageProvider (org.apache.wicket.core.request.handler.IPageProvider)16 PageProvider (org.apache.wicket.core.request.handler.PageProvider)16 IRequestHandler (org.apache.wicket.request.IRequestHandler)15 Url (org.apache.wicket.request.Url)15 Test (org.junit.Test)15 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)13 MockPage (org.apache.wicket.MockPage)12 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)3 MockPageParametersAware (org.apache.wicket.MockPageParametersAware)2 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)2 InnerPage (org.apache.wicket.core.request.mapper.PackageMapperTest.OuterPage.InnerPage)1 IRequestParameters (org.apache.wicket.request.IRequestParameters)1 StringValue (org.apache.wicket.util.string.StringValue)1