Search in sources :

Example 11 with WebResponse

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();
}
Also used : WebResponse(org.apache.wicket.request.http.WebResponse)

Example 12 with WebResponse

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>");
}
Also used : WebResponse(org.apache.wicket.request.http.WebResponse)

Example 13 with WebResponse

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);
}
Also used : WebResponse(org.apache.wicket.request.http.WebResponse) IRequestCycle(org.apache.wicket.request.IRequestCycle) Test(org.junit.Test)

Example 14 with WebResponse

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);
}
Also used : WebResponse(org.apache.wicket.request.http.WebResponse) IRequestCycle(org.apache.wicket.request.IRequestCycle) Test(org.junit.Test)

Example 15 with WebResponse

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);
}
Also used : WebResponse(org.apache.wicket.request.http.WebResponse)

Aggregations

WebResponse (org.apache.wicket.request.http.WebResponse)34 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)9 Test (org.junit.Test)7 BufferedWebResponse (org.apache.wicket.protocol.http.BufferedWebResponse)5 IRequestCycle (org.apache.wicket.request.IRequestCycle)5 Response (org.apache.wicket.request.Response)5 WebRequest (org.apache.wicket.request.http.WebRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)4 IRequestHandler (org.apache.wicket.request.IRequestHandler)3 Url (org.apache.wicket.request.Url)3 IOException (java.io.IOException)2 Application (org.apache.wicket.Application)2 Page (org.apache.wicket.Page)2 Attributes (org.apache.wicket.request.resource.IResource.Attributes)2 JSONObject (com.github.openjson.JSONObject)1 Member (com.hazelcast.core.Member)1 MemberAttributeEvent (com.hazelcast.core.MemberAttributeEvent)1 MembershipEvent (com.hazelcast.core.MembershipEvent)1 MembershipListener (com.hazelcast.core.MembershipListener)1