* @see org.apache.wicket.core.request.handler.IPageRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
*/
@Override
public final void respond(final IRequestCycle requestCycle)
{
final RequestCycle rc = (RequestCycle)requestCycle;
final WebResponse response = (WebResponse)requestCycle.getResponse();
if (responseObject.containsPage())
{
// the page itself has been added to the request target, we simply issue a redirect
// back to the page
IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
final String url = rc.urlFor(handler).toString();
response.sendRedirect(url);
return;
}
respondersFrozen = true;
for (ITargetRespondListener listener : respondListeners)
{
listener.onTargetRespond(this);
}
final Application app = page.getApplication();
page.send(app, Broadcast.BREADTH, this);
// Determine encoding
final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
responseObject.setContentType(response, encoding);
// Make sure it is not cached by a client
response.disableCaching();
try
{
final StringResponse bodyResponse = new StringResponse();
responseObject.writeTo(bodyResponse, encoding);
CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
response.write(filteredResponse);
}
finally
{
// restore the original response
rc.setResponse(response);
}
}