* Validate that each component which wanted to contribute to the header section actually was
* able to do so.
*/
private void validateHeaders()
{
HtmlHeaderContainer header = visitChildren(new IVisitor<Component, HtmlHeaderContainer>()
{
public void component(final Component component, final IVisit<HtmlHeaderContainer> visit)
{
if (component instanceof HtmlHeaderContainer)
{
visit.stop((HtmlHeaderContainer)component);
}
else
{
visit.dontGoDeeper();
}
}
});
if (header == null)
{
// the markup must at least contain a <body> tag for wicket to automatically
// create a HtmlHeaderContainer. Log an error if no header container
// was created but any of the components or behaviors want to contribute
// something to the header.
header = new HtmlHeaderContainer(HtmlHeaderSectionHandler.HEADER_ID);
add(header);
Response orgResponse = getRequestCycle().getResponse();
try
{
final StringResponse response = new StringResponse();
getRequestCycle().setResponse(response);
// Render all header sections of all components on the page
renderHead(header);
// Make sure all Components interested in contributing to the header
// and there attached behaviors are asked.
final HtmlHeaderContainer finalHeader = header;
visitChildren(new IVisitor<Component, Void>()
{
/**
* @see org.apache.wicket.IVisitor#component(org.apache.wicket.Component)
*/