use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PackageMapperTest method decodeInnerClass.
/**
* https://issues.apache.org/jira/browse/WICKET-3838
*/
@Test
public void decodeInnerClass() {
Url url = Url.parse(MOUNT_PATH + '/' + "PackageMapperTest$OuterPage$InnerPage");
IRequestHandler handler = innerClassEncoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
IRequestablePage page = ((RenderPageRequestHandler) handler).getPage();
assertEquals("InnerPage", page.getClass().getSimpleName());
assertEquals(0, page.getPageParameters().getIndexedCount());
assertTrue(page.getPageParameters().getNamedKeys().isEmpty());
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PageInstanceMapperTest method decode1.
/**
*/
@Test
public void decode1() {
Url url = Url.parse("wicket/page?4");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler h = (RenderPageRequestHandler) handler;
checkPage(h.getPage(), 4);
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class PageInstanceMapperTest method decode2.
/**
*/
@Test
public void decode2() {
Url url = Url.parse("wicket/page?4&a=3&b=3");
IRequestHandler handler = encoder.mapRequest(getRequest(url));
assertThat(handler, instanceOf(RenderPageRequestHandler.class));
RenderPageRequestHandler h = (RenderPageRequestHandler) handler;
checkPage(h.getPage(), 4);
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class DefaultExceptionMapper method createPageRequestHandler.
/**
* Creates a {@link RenderPageRequestHandler} for the target page provided by {@code pageProvider}.
*
* Uses {@link RenderPageRequestHandler.RedirectPolicy#NEVER_REDIRECT} policy to preserve the original page's URL
* for non-Ajax requests and {@link RenderPageRequestHandler.RedirectPolicy#AUTO_REDIRECT} for AJAX requests.
*
* @param pageProvider
* the page provider for the target page
* @return the request handler for the target page
*/
protected RenderPageRequestHandler createPageRequestHandler(PageProvider pageProvider) {
RequestCycle requestCycle = RequestCycle.get();
if (requestCycle == null) {
throw new IllegalStateException("there is no current request cycle attached to this thread");
}
RenderPageRequestHandler.RedirectPolicy redirect = RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT;
if (isProcessingAjaxRequest()) {
redirect = RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT;
}
return new RenderPageRequestHandler(pageProvider, redirect);
}
use of org.apache.wicket.core.request.handler.RenderPageRequestHandler in project wicket by apache.
the class HttpsMapperTest method mapRequest.
@Test
public void mapRequest() {
IRequestMapper delegate = mock(IRequestMapper.class);
HttpsMapper mapper = new HttpsMapper(delegate, new HttpsConfig());
ServletWebRequest request = mock(ServletWebRequest.class);
HttpServletRequest req = mock(HttpServletRequest.class);
when(request.getContainerRequest()).thenReturn(req);
// https handler on http request, redirect to https
setupRequest(req, "http", "localhost", 80, "/ctx", "foo=bar");
IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(SecurePage.class));
when(delegate.mapRequest(request)).thenReturn(handler);
IRequestHandler resolved = mapper.mapRequest(request);
assertThat(resolved, is(instanceOf(RedirectHandler.class)));
assertThat(((RedirectHandler) resolved).getUrl(), is("https://localhost/ctx?foo=bar"));
// http handler on http request, return the original handler
handler = new RenderPageRequestHandler(new PageProvider(InsecurePage.class));
reset(delegate);
when(delegate.mapRequest(request)).thenReturn(handler);
setupRequest(req, "http", "localhost", 80, "/ctx", "foo=bar");
resolved = mapper.mapRequest(request);
assertThat(resolved, is(sameInstance(handler)));
}
Aggregations