Refine search
public static <T> ArrayList<T> children(Class<T> type, UIComponent base) { ArrayList<T> result = new ArrayList<T>(); Iterator<UIComponent> kids = base.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent kid = kids.next(); if (type.isAssignableFrom(kid.getClass())) { result.add((T) kid); } } return result; }
public static <T> T first(Class<T> type, UIComponent base) { T result = null; Iterator<UIComponent> kids = base.getFacetsAndChildren(); while (kids.hasNext() && (result == null)) { UIComponent kid = kids.next(); if (type.isAssignableFrom(kid.getClass())) { result = (T) kid; break; } result = first(type, kid); if (result != null) { break; } } return result; }
private void resetClientIds(UIComponent component) { Iterator<UIComponent> iterator = component.getFacetsAndChildren(); while (iterator.hasNext()) { UIComponent child = iterator.next(); resetClientIds(child); child.setId(child.getId()); } }
private void removeChildState(FacesContext faces, UIComponent c) { String id = c.getId(); c.setId(id); Iterator itr = c.getFacetsAndChildren(); while (itr.hasNext()) { removeChildState(faces, (UIComponent) itr.next()); } if (childState != null) { childState.remove(c.getClientId(faces)); } }
/** * Finds the first component with the given id (NOT clientId!). * * @param id The id. * @param base The base component to start the traversal. * @return The component or null. */ public static UIComponent firstWithId(String id, UIComponent base) { if (id.equals(base.getId())) { return base; } UIComponent result = null; Iterator<UIComponent> kids = base.getFacetsAndChildren(); while (kids.hasNext() && (result == null)) { UIComponent kid = kids.next(); if (id.equals(kid.getId())) { result = kid; break; } result = firstWithId(id, kid); if (result != null) { break; } } return result; }
private Map<String, Object> saveTransientDescendantComponentStates(FacesContext facesContext, Map<String, Object> childStates, Iterator<UIComponent> childIterator, boolean saveChildFacets) { while (childIterator.hasNext()) { UIComponent child = childIterator.next(); if (!child.isTransient()) { Iterator<UIComponent> childsIterator; if (saveChildFacets) { childsIterator = child.getFacetsAndChildren(); } else { childsIterator = child.getChildren().iterator(); } childStates = saveTransientDescendantComponentStates(facesContext, childStates, childsIterator, true); Object state = child.saveTransientState(facesContext); if (state != null) { if (childStates == null) { childStates = new HashMap<>(); } childStates.put(child.getClientId(facesContext), state); } } } return childStates; }
private Map<String, Object> saveFullDescendantComponentStates(FacesContext facesContext, Map<String, Object> stateMap, Iterator<UIComponent> childIterator, boolean saveChildFacets) { while (childIterator.hasNext()) { UIComponent child = childIterator.next(); if (!child.isTransient()) { Iterator<UIComponent> childsIterator; if (saveChildFacets) { childsIterator = child.getFacetsAndChildren(); } else { childsIterator = child.getChildren().iterator(); } stateMap = saveFullDescendantComponentStates(facesContext, stateMap, childsIterator, true); Object state = child.saveState(facesContext); if (state != null) { if (stateMap == null) { stateMap = new HashMap<>(); } stateMap.put(child.getClientId(facesContext), state); } } } return stateMap; }
/** * Recursively create the initial state for the given component. * * @param facesContext the Faces context. * @param component the UI component to save the state for. * @see #saveInitialChildState(javax.faces.context.FacesContext) */ private void saveInitialChildState(FacesContext facesContext, UIComponent component) { if (component instanceof EditableValueHolder && !component.isTransient()) { String clientId = component.getClientId(facesContext); SavedState state = new SavedState(); initialChildState.put(clientId, state); state.populate((EditableValueHolder) component); } Iterator<UIComponent> iterator = component.getFacetsAndChildren(); while (iterator.hasNext()) { saveChildState(facesContext, iterator.next()); } }
private void saveChildState(FacesContext faces, UIComponent c) { if (c instanceof EditableValueHolder && !c.isTransient()) { String clientId = c.getClientId(faces); SavedState ss = getChildState().get(clientId); if (ss == null) { ss = new SavedState(); getChildState().put(clientId, ss); } ss.populate((EditableValueHolder) c); } // continue hack Iterator itr = c.getFacetsAndChildren(); while (itr.hasNext()) { saveChildState(faces, (UIComponent) itr.next()); } }
private void restoreTransientDescendantComponentStates(FacesContext facesContext, Iterator<UIComponent> childIterator, Map<String, Object> state, boolean restoreChildFacets) { while (childIterator.hasNext()) { UIComponent component = childIterator.next(); // reset the client id (see spec 3.1.6) component.setId(component.getId()); if (!component.isTransient()) { component.restoreTransientState(facesContext, (state == null) ? null : state.get(component.getClientId(facesContext))); Iterator<UIComponent> childsIterator; if (restoreChildFacets) { childsIterator = component.getFacetsAndChildren(); } else { childsIterator = component.getChildren().iterator(); } restoreTransientDescendantComponentStates(facesContext, childsIterator, state, true); } } }
Iterator itr = c.getFacetsAndChildren(); while (itr.hasNext()) { restoreChildState(faces, (UIComponent) itr.next());
boolean restoreChildFacets) { Iterator<? extends Object[]> descendantStateIterator = null; while (childIterator.hasNext()) { if (descendantStateIterator == null && state != null) { descendantStateIterator = ((Collection<? extends Object[]>) state) .iterator(); UIComponent component = childIterator.next(); Object descendantState = null; if (descendantStateIterator != null && descendantStateIterator.hasNext()) { Object[] object = descendantStateIterator.next(); childState = object[0]; descendantState = object[1]; childsIterator = component.getFacetsAndChildren();
private Collection<Object[]> saveDescendantInitialComponentStates(FacesContext facesContext, Iterator<UIComponent> childIterator, boolean saveChildFacets) { Collection<Object[]> childStates = null; while (childIterator.hasNext()) { if (childStates == null) { childStates = new ArrayList<>(); UIComponent child = childIterator.next(); if (!child.isTransient()) { childsIterator = child.getFacetsAndChildren();
Map<String, Object> descendantStateIterator = null; Iterator<? extends Object[]> descendantFullStateIterator = null; while (childIterator.hasNext()) { if (descendantStateIterator == null && state != null) { descendantStateIterator = (Map<String, Object>) state; descendantFullStateIterator = ((Collection<? extends Object[]>) initialState).iterator(); UIComponent component = childIterator.next(); && descendantFullStateIterator.hasNext()) { Object[] object = descendantFullStateIterator.next(); childInitialState = object[0]; descendantInitialState = object[1]; childsIterator = component.getFacetsAndChildren();
public static <T> ArrayList<T> children(Class<T> type, UIComponent base) { ArrayList<T> result = new ArrayList<T>(); Iterator<UIComponent> kids = base.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent kid = (UIComponent) kids.next(); if (type.isAssignableFrom(kid.getClass())) { result.add((T) kid); } } return result; }
private int countViewManagers(UIComponent uic){ int count = 0; if( uic instanceof ViewManager ){ count++; } Iterator<UIComponent> iter = uic.getFacetsAndChildren(); while( iter.hasNext() ){ UIComponent child = iter.next(); count += countViewManagers(child); } return count; }
@SuppressWarnings("unchecked") private static void findSubForms(final List<AbstractUIForm> collect, final UIComponent component) { final Iterator<UIComponent> kids = component.getFacetsAndChildren(); while (kids.hasNext()) { final UIComponent child = kids.next(); if (child instanceof AbstractUIForm) { collect.add((AbstractUIForm) child); } else { findSubForms(collect, child); } } }
private static boolean invokeOnComponentFacetsAndChildren( FacesContext context, UIComponent component, String clientId, ContextCallback callback) { for (java.util.Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) { UIComponent child = it.next(); if (child.invokeOnComponent(context, clientId, callback)) { return true; } } return false; } }
private static boolean invokeOnComponentFacetsAndChildren( FacesContext context, UIComponent component, String clientId, ContextCallback callback) { for (java.util.Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) { UIComponent child = it.next(); if (child.invokeOnComponent(context, clientId, callback)) { return true; } } return false; }
private static FileEntry findFileEntry(UIComponent parent) { Iterator<UIComponent> kids = parent.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent kid = kids.next(); if (kid instanceof FileEntry) { return (FileEntry) kid; } final FileEntry grandKid = findFileEntry(kid); if (grandKid != null) { return grandKid; } } return null; }