use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class ComponentRenderingRequestHandler method respond.
@Override
public void respond(IRequestCycle requestCycle) {
// preventing the response to component from being cached
if (requestCycle.getResponse() instanceof WebResponse) {
WebResponse response = (WebResponse) requestCycle.getResponse();
response.disableCaching();
}
component.beforeRender();
component.renderPart();
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class EmptyAjaxRequestHandler method respond.
/**
* {@inheritDoc}
*/
@Override
public void respond(IRequestCycle requestCycle) {
WebResponse response = (WebResponse) requestCycle.getResponse();
final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
response.setContentType("text/xml; charset=" + encoding);
// Make sure it is not cached by a client
response.disableCaching();
response.write("<?xml version=\"1.0\" encoding=\"");
response.write(encoding);
response.write("\"?><ajax-response></ajax-response>");
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class RedirectRequestHandlerTest method tempMovedShouldRedirect.
/**
* tempMovedShouldRedirect()
*/
@Test
public void tempMovedShouldRedirect() {
RedirectRequestHandler handler = new RedirectRequestHandler(REDIRECT_URL, HttpServletResponse.SC_MOVED_TEMPORARILY);
IRequestCycle requestCycle = Mockito.mock(IRequestCycle.class);
WebResponse webResponse = Mockito.mock(WebResponse.class);
Mockito.when(requestCycle.getResponse()).thenReturn(webResponse);
handler.respond(requestCycle);
Mockito.verify(webResponse).sendRedirect(REDIRECT_URL);
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class RedirectRequestHandlerTest method permenanentlyMovedShouldSetLocationHeader.
/**
* permenanentlyMovedShouldSetLocationHeader()
*/
@Test
public void permenanentlyMovedShouldSetLocationHeader() {
RedirectRequestHandler handler = new RedirectRequestHandler(REDIRECT_URL, HttpServletResponse.SC_MOVED_PERMANENTLY);
IRequestCycle requestCycle = Mockito.mock(IRequestCycle.class);
WebResponse webResponse = Mockito.mock(WebResponse.class);
Mockito.when(requestCycle.getResponse()).thenReturn(webResponse);
handler.respond(requestCycle);
Mockito.verify(webResponse).setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
Mockito.verify(webResponse).setHeader("Location", REDIRECT_URL);
}
use of org.apache.wicket.request.http.WebResponse in project wicket by apache.
the class ErrorCodeRequestHandler method respond.
/**
* Respond by sending the set errorCode and optionally the message to the browser.
*
* @see org.apache.wicket.request.IRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
*/
@Override
public void respond(final IRequestCycle requestCycle) {
WebResponse webResponse = (WebResponse) requestCycle.getResponse();
webResponse.sendError(errorCode, message);
}
Aggregations