Example usage for org.apache.wicket.request.http WebResponse reset

List of usage examples for org.apache.wicket.request.http WebResponse reset

Introduction

In this page you can find the example usage for org.apache.wicket.request.http WebResponse reset.

Prototype

public void reset() 

Source Link

Document

Called when the Response needs to reset itself.

Usage

From source file:com.conwax.ajax.SimpleAjaxRequestTarget.java

License:Apache License

public void respond(IRequestCycle requestCycle) {
    final WebResponse response = (WebResponse) requestCycle.getResponse();

    response.reset();
    // Make sure it is not cached by a client
    response.disableCaching();/*from   w  ww  .  j  a v  a  2 s .c  o m*/

    if (component.getRenderBodyOnly() == true) {
        throw new IllegalStateException(
                "Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: "
                        + component.toString());
    }

    component.setOutputMarkupId(true);

    // Initialize temporary variables
    final Page page = component.findParent(Page.class);
    if (page == null) {
        // dont throw an exception but just ignore this component,
        // somehow
        // it got removed from the page.
        LOG.debug("component: " + component + " with markupid: " + component.getMarkupId()
                + " not rendered because it was already removed from page");
        return;
    }

    page.startComponentRender(component);

    try {
        component.prepareForRender();

        // render any associated headers of the component
        // forget about Header Contribs
        // writeHeaderContribution(response, component);
    } catch (RuntimeException e) {
        try {
            component.afterRender();
        } catch (RuntimeException e2) {
            // ignore this one could be a result off.
        }
        throw e;
    }

    try {
        component.render();
    } catch (RuntimeException e) {
        response.reset();
        throw e;
    }

    page.endComponentRender(component);

}