// written to its body. Thus we first write the output into a
// StringResponse and if not empty, we copy it to the original
// web response.
// Temporarily replace the web response with a String response
final Response webResponse = getResponse();
try
{
// Create a (string) response for all headers contributed by any component on the Page.
final StringResponse response = new StringResponse();
getRequestCycle().setResponse(response);
IHeaderResponse headerResponse = getHeaderResponse();
if (!response.equals(headerResponse.getResponse()))
{
getRequestCycle().setResponse(headerResponse.getResponse());
}
// Render the header sections of all components on the page
AbstractHeaderRenderStrategy.get().renderHeader(this,
new HeaderStreamState(markupStream, openTag), getPage());
// Close the header response before rendering the header container itself
// See https://issues.apache.org/jira/browse/WICKET-3728
headerResponse.close();
// Cleanup extraneous CR and LF from the response
CharSequence output = getCleanResponse(response);
// Automatically add <head> if necessary
if (output.length() > 0)
{
if (renderOpenAndCloseTags())
{
webResponse.write("<head>");
}
webResponse.write(output);
if (renderOpenAndCloseTags())
{
webResponse.write("</head>");
}
}
}
finally
{