public final class Components extends Object
UIComponent
.Modifier and Type | Method and Description |
---|---|
static <T extends UIComponent> |
findComponent(String clientId)
Returns the UI component matching the given client ID search expression.
|
static <T extends UIComponent> |
findComponentInChildren(UIComponent component,
String clientId)
Returns the UI component matching the given client ID search expression relative to the point
in the component tree of the given component, searching only in its children.
|
static <T extends UIComponent> |
findComponentInParents(UIComponent component,
String clientId)
Returns the UI component matching the given client ID search expression relative to the point
in the component tree of the given component, searching only in its parents.
|
static <T extends UIComponent> |
findComponentRelatively(UIComponent component,
String clientId)
Returns the UI component matching the given client ID search expression relative to the point
in the component tree of the given component.
|
static <T extends UIComponent> |
getClosestParent(UIComponent component,
Class<T> parentType)
Returns from the given component the closest parent of the given parent type, or
null if none
is found. |
static UIComponent |
getCurrentComponent()
Returns the current UI component from the EL context.
|
static UIForm |
getCurrentForm()
Returns the currently submitted UI form component, or
null if there is none, which may happen when
the current request is not a postback request at all, or when the view has been changed by for example a
successful navigation. |
static String |
getLabel(UIComponent input)
Returns the value of the
label attribute associated with the given UI component if any, else
the client ID. |
static Object |
getOptionalLabel(UIComponent input)
Returns the value of the
label attribute associated with the given UI component if any, else
null. |
static Object |
getValue(EditableValueHolder component)
Returns the value of the given editable value holder component without the need to know if the given component
has already been converted/validated or not.
|
static boolean |
hasSubmittedValue(EditableValueHolder component)
Returns whether the given editable value holder component has a submitted value.
|
static boolean |
isEditable(UIInput input)
Returns whether the given UI input component is editable.
|
static <T extends UIComponent> |
validateHasDirectParent(UIComponent component,
Class<T> parentType)
Validate if the given component has a direct parent of the given parent type.
|
static void |
validateHasNoChildren(UIComponent component)
Validate if the given component has no children.
|
static <T extends UIComponent> |
validateHasParent(UIComponent component,
Class<T> parentType)
Validate if the given component has a parent of the given parent type.
|
public static UIComponent getCurrentComponent()
UIComponent.getCurrentComponent(FacesContext)
public static <T extends UIComponent> T findComponent(String clientId)
clientId
- The client ID search expression.ClassCastException
- When T
is of wrong type.UIComponent.findComponent(String)
public static <T extends UIComponent> T findComponentRelatively(UIComponent component, String clientId)
component
- the component from which the relative search is started.clientId
- The client ID search expression.ClassCastException
- When T
is of wrong type.UIComponent.findComponent(String)
public static <T extends UIComponent> T findComponentInParents(UIComponent component, String clientId)
component
- the component from which the relative search is started.clientId
- The client ID search expression.ClassCastException
- When T
is of wrong type.UIComponent.findComponent(String)
public static <T extends UIComponent> T findComponentInChildren(UIComponent component, String clientId)
component
- the component from which the relative search is started.clientId
- The client ID search expression.ClassCastException
- When T
is of wrong type.UIComponent.findComponent(String)
public static <T extends UIComponent> T getClosestParent(UIComponent component, Class<T> parentType)
null
if none
is found.T
- The generic parent type.component
- The component to return the closest parent of the given parent type for.parentType
- The parent type.null
if none
is found.ClassCastException
- When T
is of wrong type.public static UIForm getCurrentForm()
null
if there is none, which may happen when
the current request is not a postback request at all, or when the view has been changed by for example a
successful navigation.UIForm.isSubmitted()
public static boolean isEditable(UIInput input)
input
- The UI input component to be checked.true
if the given UI input component is editable.public static String getLabel(UIComponent input)
label
attribute associated with the given UI component if any, else
the client ID. It never returns null.input
- The UI input component for which the label is to be retrieved.label
attribute associated with the given UI component if any, else
the client ID.public static Object getOptionalLabel(UIComponent input)
label
attribute associated with the given UI component if any, else
null.input
- The UI input component for which the label is to be retrieved.label
attribute associated with the given UI component if any, else
null.public static Object getValue(EditableValueHolder component)
component
- The editable value holder component to obtain the value for.public static boolean hasSubmittedValue(EditableValueHolder component)
component
- The editable value holder component to be checked.true
if the given editable value holder component has a submitted value, otherwise
false
.public static <T extends UIComponent> void validateHasParent(UIComponent component, Class<T> parentType) throws IllegalArgumentException
component
- The component to be validated.parentType
- The parent type to be checked.IllegalArgumentException
- When the given component doesn't have any parent of the given type.public static <T extends UIComponent> void validateHasDirectParent(UIComponent component, Class<T> parentType) throws IllegalArgumentException
component
- The component to be validated.parentType
- The parent type to be checked.IllegalArgumentException
- When the given component doesn't have a direct parent of the given type.public static void validateHasNoChildren(UIComponent component) throws IllegalArgumentException
component
- The component to be validated.IllegalArgumentException
- When the given component has any children.