Java examples for JSF:UIComponent
Recursively traverse the passed in JSF component structure and call the passed in visitor.
import javax.faces.component.UIComponent; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main{ /**/* w w w .j av a 2 s . com*/ * Recursively traverse the passed in component structure and call the passed in visitor. * * @param baseComponent * @param depth * @param visitor * @return */ public static boolean recurseChildren(UIComponent baseComponent, int depth, UIComponentVisitor visitor) { if (visitor.visit(baseComponent, depth) == false) { // Abort return false; } if (baseComponent.getFacetsAndChildren() != null) { Iterator<UIComponent> childComponentIterator = baseComponent .getFacetsAndChildren(); while (childComponentIterator.hasNext()) { UIComponent childComponent = childComponentIterator.next(); if (recurseChildren(childComponent, depth + 1, visitor) == false) { // Abort return false; } } } // Keep going return true; } }