/** * Use {@link ComponentTraversalUtils#closestForm(javax.faces.context.FacesContext, javax.faces.component.UIComponent)} instead. * * @param context * @param component * @return * @deprecated */ @Deprecated public static UIComponent findParentForm(FacesContext context, UIComponent component) { return ComponentTraversalUtils.closestForm(context, component); }
UniqueIdVendor parentUniqueIdVendor = ComponentTraversalUtils.closestUniqueIdVendor(this); UIComponent namingContainer = ComponentTraversalUtils.closestNamingContainer(this); if (namingContainer != null) { String containerClientId = namingContainer.getContainerClientId(context);
@Deprecated public static String findComponentClientId(String id) { FacesContext facesContext = FacesContext.getCurrentInstance(); UIComponent component = ComponentTraversalUtils.firstWithId(id, facesContext.getViewRoot()); return component.getClientId(facesContext); }
public static UIComponent closestNamingContainer(UIComponent component) { return (UIComponent) closest(NamingContainer.class, component); } }
private String createUniqueId(FacesContext fc, UIComponent source) { UniqueIdVendor parentUniqueIdVendor = ComponentTraversalUtils.closestUniqueIdVendor(source); if (parentUniqueIdVendor == null) { UIViewRoot viewRoot = fc.getViewRoot(); if (viewRoot != null) { return viewRoot.createUniqueId(fc, null); } else { throw new FacesException("Cannot create Id for UIParameter attached to " + source.getClass().getCanonicalName()); } } return parentUniqueIdVendor.createUniqueId(fc, null); } }
@Override public void resolveComponents(FacesContext context, UIComponent source, UIComponent last, String expression, List<UIComponent> components, int options) { ComponentTraversalUtils.withId( extractId(expression), last, components); }
private static void resolveComponentById(UIComponent source, String expression, char seperatorChar, FacesContext context, ContextCallback callback) { ComponentTraversalUtils.firstById(expression, source, seperatorChar, context, callback); }
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; }
public static UniqueIdVendor closestUniqueIdVendor(UIComponent component) { return closest(UniqueIdVendor.class, component); }
public static void withId(String id, UIComponent base, List<UIComponent> components) { if (id.equals(base.getId())) { components.add(base); } if (base.getFacetCount() > 0) { for (UIComponent facet : base.getFacets().values()) { withId(id, facet, components); } } if (base.getChildCount() > 0) { for (int i = 0, childCount = base.getChildCount(); i < childCount; i++) { UIComponent child = base.getChildren().get(i); withId(id, child, components); } } }
private static void resolveComponentById(UIComponent source, String expression, String separatorString, FacesContext context, ContextCallback callback) { ComponentTraversalUtils.firstById(expression, source, separatorString, context, callback); }
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 = (UIComponent) kids.next(); if (type.isAssignableFrom(kid.getClass())) { result = (T) kid; break; } result = first(type, kid); if (result != null) { break; } } return result; }
protected String buildOnclick(FacesContext context, SplitButton button) throws IOException { StringBuilder onclick = SharedStringBuilder.get(context, SB_BUILD_ONCLICK); if (button.getOnclick() != null) { onclick.append(button.getOnclick()).append(";"); } if (button.isAjax()) { onclick.append(buildAjaxRequest(context, button)); } else { UIForm form = ComponentTraversalUtils.closestForm(context, button); if (form == null) { throw new FacesException("SplitButton : \"" + button.getClientId(context) + "\" must be inside a form element"); } onclick.append(buildNonAjaxRequest(context, button, form, null, false)); } String onclickBehaviors = getEventBehaviors(context, button, "click", null); if (onclickBehaviors != null) { onclick.append(onclickBehaviors).append(";"); } return onclick.toString(); }
final UniqueIdVendor parentUniqueIdVendor = ComponentTraversalUtils.closestUniqueIdVendor(this); final UIComponent namingContainer = ComponentTraversalUtils.closestNamingContainer(this); if (namingContainer != null) { final String containerClientId = namingContainer.getContainerClientId(context);
@Override public UIComponent resolveComponent(FacesContext context, UIComponent source, UIComponent last, String expression, int options) { return ComponentTraversalUtils.firstWithId(extractId(expression), last); }
public static UIForm closestForm(FacesContext context, UIComponent component) { return closest(UIForm.class, component); }
public void resolveComponents(FacesContext context, UIComponent source, UIComponent last, String expression, List<UIComponent> components, int options) { ComponentTraversalUtils.withId( extractId(expression), last, components); }
public AjaxRequestBuilder form(AjaxSource source, UIComponent component, UIForm formComponent) { String result = null; String form = source.getForm(); if (LangUtils.isValueBlank(form)) { if (formComponent == null) { formComponent = ComponentTraversalUtils.closestForm(context, component); } if (formComponent == null) { if (context.isProjectStage(ProjectStage.Development)) { String message = "Component '" + component.getClientId(context) + "' should be inside a form or should reference a form via its form attribute." + " We will try to find a fallback form on the client side."; LOG.info(message); } } else { result = formComponent.getClientId(context); } } else { result = SearchExpressionFacade.resolveClientId(context, component, source.getForm()); } if (result != null) { buffer.append(",f:\"").append(result).append("\""); } return this; }
UniqueIdVendor parentUniqueIdVendor = ComponentTraversalUtils.closestUniqueIdVendor(this); UIComponent namingContainer = ComponentTraversalUtils.closestNamingContainer(this); if (namingContainer != null) { String containerClientId = namingContainer.getContainerClientId(context);
/** * 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; }