public static int getFixedHeightForPanel(UIComponent component, FacesContext facesContext) {
int height = -1;
// first ask layoutManager
UIComponent layout = component.getFacet(FACET_LAYOUT);
if (layout != null) {
LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, layout);
height = renderer.getFixedHeight(facesContext, component);
}
if (height < 0) {
if (component.getChildren().size() == 0) {
height = 0;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Can't calculate fixedHeight! "
+ "using estimation by contained components. for "
+ component.getClientId(facesContext) + " = "
+ component.getClass().getName() + " "
+ component.getRendererType());
}
height = 0;
for (Object o : component.getChildren()) {
UIComponent child = (UIComponent) o;
LayoutInformationProvider renderer = ComponentUtil.getRenderer(facesContext, child);
if (renderer == null
&& child instanceof UINamingContainer
&& child.getChildren().size() > 0) {
// this is a subview component ??
renderer = ComponentUtil.getRenderer(facesContext, (UIComponent) child.getChildren().get(0));
}
if (renderer != null) {
int h = renderer.getFixedHeight(facesContext, child);
if (h > 0) {
height += h;
}
}
}