/**
* @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle)
*/
public final void respond(final RequestCycle requestCycle)
{
final WebResponse response = (WebResponse)requestCycle.getResponse();
if (markupIdToComponent.values().contains(page))
{
// the page itself has been added to the request target, we simply issue a redirect back
// to the page
final String url = requestCycle.urlFor(page).toString();
response.redirect(url);
return;
}
Iterator it = respondListeners.iterator();
while (it.hasNext())
{
ITargetRespondListener listener = (ITargetRespondListener)it.next();
listener.onTargetRespond(this);
}
final Application app = Application.get();
// Determine encoding
final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
response.setCharacterEncoding(encoding);
response.setContentType("text/xml; charset=" + encoding);
// Make sure it is not cached by a client
response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
response.setHeader("Cache-Control", "no-cache, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.write("<?xml version=\"1.0\" encoding=\"");
response.write(encoding);
response.write("\"?>");
response.write("<ajax-response>");
// invoke onbeforerespond event on listeners
fireOnBeforeRespondListeners();
// normal behavior
it = prependJavascripts.iterator();
while (it.hasNext())
{
String js = (String)it.next();
respondInvocation(response, js);
}
// process added components
respondComponents(response);
fireOnAfterRespondListeners(response);
// execute the dom ready javascripts as first javascripts
// after component replacement
it = domReadyJavascripts.iterator();
while (it.hasNext())
{
String js = (String)it.next();
respondInvocation(response, js);
}
it = appendJavascripts.iterator();
while (it.hasNext())
{
String js = (String)it.next();
respondInvocation(response, js);
}
response.write("</ajax-response>");
}