Java Code Examples for javax.faces.component.UIComponent#getFacetsAndChildren()
The following examples show how to use
javax.faces.component.UIComponent#getFacetsAndChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FindPartialIdRecursiveExpressionResolver.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
public List<UIComponent> findIdRecursively(UIComponent parent, String id) { if (null==parent) return null; List<UIComponent> result = new ArrayList<UIComponent>(); boolean found = matches(id, parent); if (found) { result.add(parent); } Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren(); while (facetsAndChildren.hasNext()) { UIComponent child = facetsAndChildren.next(); List<UIComponent> subresult = findIdRecursively(child, id); if (null != subresult) result.addAll(subresult); } return result; }
Example 2
Source File: FindIdRecursiveExpressionResolver.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
public List<UIComponent> findIdsRecursively(UIComponent parent, String id) { if (null==parent) return null; List<UIComponent> result = null; if (id.equals(parent.getId())) { result = new ArrayList<UIComponent>(); result.add(parent); } Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren(); while (facetsAndChildren.hasNext()) { UIComponent child = facetsAndChildren.next(); List<UIComponent> childresult = findIdsRecursively(child, id); if (null != childresult && (!childresult.isEmpty())) { if (null == result) { result = new ArrayList<UIComponent>(); } result.addAll(childresult); } } return result; }
Example 3
Source File: FindPartialIdExpressionResolver.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
public List<UIComponent> findId(UIComponent parent, String id) { if (null==parent) return null; List<UIComponent> result = new ArrayList<UIComponent>(); boolean found = matches(id, parent); if (found) { result.add(parent); } Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren(); while (facetsAndChildren.hasNext()) { UIComponent child = facetsAndChildren.next(); found = matches(id, child); if (found) { result.add(child); } } return result; }
Example 4
Source File: RadiobuttonRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
private List<UIComponent> findComponentsByName(UIComponent c, String name) { List<UIComponent> result = new ArrayList<UIComponent>(); Iterator<UIComponent> children = c.getFacetsAndChildren(); while(children.hasNext()) { UIComponent comp = children.next(); if (comp instanceof Radiobutton) { if (name.equals(((Radiobutton)comp).getName())) { result.add(comp); } } List<UIComponent> r = findComponentsByName(comp, name); if (!r.isEmpty()) { result.addAll(r); } } return result; }
Example 5
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
private void saveChildState(FacesContext faces, UIComponent c) { if (c instanceof EditableValueHolder && !c.isTransient()) { String clientId = c.getClientId(faces); SavedState ss = this.getChildState().get(clientId); if (ss == null) { ss = new SavedState(); this.getChildState().put(clientId, ss); } ss.populate((EditableValueHolder) c); } // continue hack Iterator itr = c.getFacetsAndChildren(); while (itr.hasNext()) { saveChildState(faces, (UIComponent) itr.next()); } }
Example 6
Source File: WebUtil.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public static UIComponent findComponentById(UIComponent parent, String id) { if (id.equals(parent.getId())) { return parent; } Iterator<UIComponent> kids = parent.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent kid = kids.next(); UIComponent found = findComponentById(kid, id); if (found != null) { return found; } } return null; }
Example 7
Source File: FindIdExpressionResolver.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
public UIComponent findId(UIComponent parent, String id) { if (null==parent) return null; if (id.equals(parent.getId())) { return parent; } Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren(); while (facetsAndChildren.hasNext()) { UIComponent child = facetsAndChildren.next(); if (id.equals(child.getId())) { return child; } } return null; }
Example 8
Source File: BsfUtils.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Finds component with the given id */ public static UIComponent findComponent(UIComponent c, String id) { if (id.equals(c.getId())) { return c; } Iterator<UIComponent> kids = c.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent found = findComponent(kids.next(), id); if (found != null) { return found; } } return null; }
Example 9
Source File: RadiobuttonRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private UIComponent findComponentByName(UIComponent c, String name) { Iterator<UIComponent> children = c.getFacetsAndChildren(); while(children.hasNext()) { UIComponent comp = children.next(); if (comp instanceof Radiobutton) { if (name.equals(((Radiobutton)comp).getName())) return comp; } UIComponent r = findComponentByName(comp, name); if (r != null) return r; } return null; }
Example 10
Source File: DataTableRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private void resetClientIdCacheRecursively(UIComponent c) { String id = c.getId(); if (null != id) { c.setId(id); // this strange operation clears the cache of the clientId } Iterator<UIComponent> children = c.getFacetsAndChildren(); if (children != null) { while (children.hasNext()) { UIComponent kid = children.next(); resetClientIdCacheRecursively(kid); } } }
Example 11
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
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 (this.childState != null) { this.childState.remove(c.getClientId(faces)); } }
Example 12
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private void restoreChildState(FacesContext faces, UIComponent c) { // reset id String id = c.getId(); c.setId(id); // hack if (c instanceof EditableValueHolder) { EditableValueHolder evh = (EditableValueHolder) c; String clientId = c.getClientId(faces); SavedState ss = this.getChildState().get(clientId); if (ss != null) { ss.apply(evh); } else { String childId = clientId.substring(initialClientId.length() + 1); childId = childId.substring(childId.indexOf(getSeparatorChar(faces)) + 1); childId = initialClientId + getSeparatorChar(faces) + childId; if (initialChildState.containsKey(childId)) { SavedState initialState = initialChildState.get(childId); initialState.apply(evh); } else { NullState.apply(evh); } } } // continue hack Iterator itr = c.getFacetsAndChildren(); while (itr.hasNext()) { restoreChildState(faces, (UIComponent) itr.next()); } }
Example 13
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * 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()); } }
Example 14
Source File: TabRepeat.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private void resetClientIds(UIComponent component) { Iterator<UIComponent> iterator = component.getFacetsAndChildren(); while (iterator.hasNext()) { UIComponent child = iterator.next(); resetClientIds(child); child.setId(child.getId()); } }
Example 15
Source File: AddResourcesListener.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Check all components in page to find one that has as resource library the * target library. I use this method to check existence of a BsF component * because, at this level, the getComponentResource returns always null * * @param parent the parent component * @param targetLib the lib to search * @return */ public static UIComponent findBsfComponent(UIComponent parent, String targetLib) { if (targetLib.equalsIgnoreCase((String) parent.getAttributes().get("library"))) { return parent; } Iterator<UIComponent> kids = parent.getFacetsAndChildren(); while (kids.hasNext()) { UIComponent found = findBsfComponent(kids.next(), targetLib); if (found != null) { return found; } } return null; }
Example 16
Source File: EvaluationManagementBackingBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private UIComponent findComponent(UIComponent c, String id) { if (id.equals(c.getId())) { return c; } Iterator<UIComponent> childIt = c.getFacetsAndChildren(); while (childIt.hasNext()) { UIComponent found = findComponent(childIt.next(), id); if (found != null) { return found; } } return null; }