in wicket-core/src/main/java/org/apache/wicket/Page.java [561:669]
private void checkRendering(final MarkupContainer renderedContainer)
{
// If the application wants component uses checked and
// the response is not a redirect
final DebugSettings debugSettings = getApplication().getDebugSettings();
if (debugSettings.getComponentUseCheck())
{
final List<Component> unrenderedComponents = new ArrayList<Component>();
final StringBuilder buffer = new StringBuilder();
renderedContainer.visitChildren(new IVisitor<Component, Void>()
{
@Override
public void component(final Component component, final IVisit<Void> visit)
{
// If component never rendered
if (renderedComponents == null || !renderedComponents.contains(component))
{
// If not an auto component ...
if (!component.isAuto() && component.isVisibleInHierarchy())
{
// Increase number of unrendered components
unrenderedComponents.add(component);
// Add to explanatory string to buffer
buffer.append(Integer.toString(unrenderedComponents.size()))
.append(". ")
.append(component.toString(true))
.append('\n');
String metadata = component.getMetaData(Component.CONSTRUCTED_AT_KEY);
if (metadata != null)
{
buffer.append(metadata).append('\n');
}
metadata = component.getMetaData(Component.ADDED_AT_KEY);
if (metadata != null)
{
buffer.append(metadata).append('\n');
}
}
else
{
// if the component is not visible in hierarchy we
// should not visit its children since they are also
// not visible
visit.dontGoDeeper();
}
}
}
});
// Throw exception if any errors were found
if (unrenderedComponents.size() > 0)
{
renderedComponents = null;
List<Component> transparentContainerChildren = Generics.newArrayList();
Iterator<Component> iterator = unrenderedComponents.iterator();
outerWhile : while (iterator.hasNext())
{
Component component = iterator.next();
// If any of the transparentContainerChildren is a parent to component, then
// ignore it.
for (Component transparentContainerChild : transparentContainerChildren)
{
MarkupContainer parent = component.getParent();
while (parent != null)
{
if (parent == transparentContainerChild)
{
iterator.remove();
continue outerWhile;
}
parent = parent.getParent();
}
}
if (hasInvisibleTransparentChild(component.getParent(), component))
{
// If we found a transparent container that isn't visible then ignore this
// component and only do a debug statement here.
if (log.isDebugEnabled())
{
log.debug(
"Component {} wasn't rendered but might have a transparent parent.",
component);
}
transparentContainerChildren.add(component);
iterator.remove();
continue outerWhile;
}
}
// if still > 0
if (unrenderedComponents.size() > 0)
{
// Throw exception
throw new WicketRuntimeException(
"The component(s) below failed to render. Possible reasons could be that:\n\t1) you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered),\n\t2) if your components were added in a parent container then make sure the markup for the child container includes them in <wicket:extend>.\n\n" +
buffer.toString());
}
}
}
// Get rid of set
renderedComponents = null;
}