public final class JsfTreeUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
convertComponentForToClientFor(javax.faces.context.FacesContext context,
String componentForId,
javax.faces.component.UIComponent component)
Utility method to convert the "component id" as used in a for attribute to a client id.
|
static <T extends javax.faces.component.UIComponent> |
findAll(javax.faces.component.UIComponent uiComponent,
Class<T> type)
Finds all UI components of a certain type.
|
static <T extends javax.faces.component.UIComponent> |
findAll(javax.faces.component.UIComponent uiComponent,
Class<T> type,
String attributeName)
Finds all UI components of a certain type that have an attribute with the supplied attributeName.
|
static javax.faces.component.UIComponent |
findComponent(javax.faces.component.UIComponent startingComponent,
String id)
Finds the component with the supplied id.
|
static String |
getClientIdOfForm(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent uiComponent)
Gets the client id of the form in which the supplied uiComponent is nested.
|
static <T extends javax.faces.component.UIComponent> |
getParent(javax.faces.component.UIComponent uiComponent,
Class<T> type)
Gets the parent of the supplied uiComponent that is of the supplied type.
|
static String |
toString(javax.faces.component.UIComponent uiComponent)
Creates a String representation of the supplied uiComponent.
|
static String |
toString(javax.faces.component.UIViewRoot uiViewRoot)
Creates a String representation of the supplied uiViewRoot.
|
static void |
walkTheTree(javax.faces.component.UIComponent uiComponent,
UIComponentCallBack uiComponentCallBack)
Walks the component tree.
|
public static String getClientIdOfForm(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent)
facesContext - The FacesContext.uiComponent - Component to get the form id for.NullPointerException - When the supplied uiComponent is null.public static <T extends javax.faces.component.UIComponent> T getParent(javax.faces.component.UIComponent uiComponent,
Class<T> type)
UIForm uiForm = JsfTreeUtil.getParent(uiComponent, UIForm.class);T - The type the parent of the supplied uiComponent must have.uiComponent - The UIComponent for which the parent component must be located.type - The type of the parent component.NullPointerException - When the supplied uiComponent is null.public static void walkTheTree(javax.faces.component.UIComponent uiComponent,
UIComponentCallBack uiComponentCallBack)
uiComponent - The uiComponent to walk.uiComponentCallBack - For each UIComponent found in the supplied uiComponent, the
UIComponentCallBack.call(UIComponent, int) method is called.NullPointerException - When either the supplied uiViewRoot or uiComponentCallBack is null.public static <T extends javax.faces.component.UIComponent> List<T> findAll(javax.faces.component.UIComponent uiComponent, Class<T> type)
final List>UIPanel> panels = JsfTreeUtil.findAll(JsfUtil.getViewRoot(), UIPanel.class);
The code above locates all UIComponent objects of type UIPanel.T - The type of the UIComponent to find.uiComponent - The UIViewRoot to search.type - The type of UIComponent to search.NullPointerException - When either the supplied uiComponent or type is null.public static <T extends javax.faces.component.UIComponent> List<T> findAll(javax.faces.component.UIComponent uiComponent, Class<T> type, String attributeName)
<h:outputLabel for="idFor" value="..."/>
the for property wont't be found by this method. Example:
final List>UIPanel> panels = JsfTreeUtil.findAll(JsfUtil.getViewRoot(), UIInput.class, "attributeName");
The code above locates all UIComponent objects of type UIInput that have an attribute named "attributeName".T - The type of the UIComponent to find.uiComponent - The uiComponent to start searching from.type - The type of UIComponent to search.attributeName - The name of the attribute.IllegalArgumentException - When the supplied attributeName is empty.NullPointerException - When either the supplied uiViewRoot or type or attributeName is null.public static String convertComponentForToClientFor(javax.faces.context.FacesContext context, String componentForId, javax.faces.component.UIComponent component)
<h:outputLabel for="idAge" value="Age:" />
<h:panelGroup>
<h:inputText id="idAge">
<f:validateLength minimum="1" maximum="3" />
<f:validateLongRange minimum="0" maximum="120" />
</h:inputText>
<jf:message for="idAge" />
</h:panelGroup>
In the previous example the componentForId would contain "idAge" and the component would be the message component.context - The FacesContext.componentForId - The value of a for attribute containing a component id.
component - The component that contains the for attribute.NullPointerException - When either the supplied context, componentForId or component is null.IllegalArgumentException - When the supplied componentForId is empty.public static javax.faces.component.UIComponent findComponent(javax.faces.component.UIComponent startingComponent,
String id)
startingComponent - The component to start the search from.id - The id of the component to search for.NullPointerException - When the supplied id is null.IllegalArgumentException - When the supplied id is empty.public static String toString(javax.faces.component.UIViewRoot uiViewRoot)
uiViewRoot - The UIViewRoot to create a String representation of.NullPointerException - When the supplied uiViewRoot is null.public static String toString(javax.faces.component.UIComponent uiComponent)
uiComponent - The UI Component to create a String representation of.Copyright © 2008–2018. All rights reserved.