public static int getRenderedChildCount(UIComponent component) {
        int renderedChildCount = 0;

        for (int i = 0; i < component.getChildCount(); i++) {
            UIComponent child = component.getChildren().get(i);
            if (child.isRendered()) {
                renderedChildCount++;
            }
        }

        return renderedChildCount;
    }
Execute a callback in a stateless scope by temporarily removing and restoring a variable from the FacesContext attributes.

@param context The FacesContext used for accessing attributes
@param var The variable to be temporarily removed and restored in the context attributes
@param runnable The callback to be executed
@param <E> The type of Throwable that may be thrown
@throws E If the callback throws an exception of type E
primefaces/src/main/java/org/primefaces/util/ComponentUtils.java