if (log.isDebugEnabled())
{
log.debug("internalRenderHead: {}", toString(false));
}
IHeaderResponse response = container.getHeaderResponse();
// Allow component to contribute
if (response.wasRendered(this) == false)
{
StringResponse markupHeaderResponse = new StringResponse();
Response oldResponse = getResponse();
RequestCycle.get().setResponse(markupHeaderResponse);
try
{
// Make sure the markup source strategy contributes to the header first
// to be backward compatible. WICKET-3761
getMarkupSourcingStrategy().renderHead(this, container);
CharSequence headerContribution = markupHeaderResponse.getBuffer();
if (Strings.isEmpty(headerContribution) == false)
{
response.render(StringHeaderItem.forString(headerContribution));
}
}
finally
{
RequestCycle.get().setResponse(oldResponse);
}
// Then let the component itself to contribute to the header
renderHead(this, response);
response.markRendered(this);
}
// Then ask all behaviors
for (Behavior behavior : getBehaviors())
{
if (isBehaviorAccepted(behavior))
{
if (response.wasRendered(behavior) == false)
{
behavior.renderHead(this, response);
List<IClusterable> pair = Arrays.asList(this, behavior);
response.markRendered(pair);
}
}
}
}
}