public final class JsfComponentUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
getAttribute(javax.faces.component.UIComponent uiComponent,
String name)
Convenience method to get an attribute from a component.
|
static <T> T |
getAttribute(javax.faces.component.UIComponent uiComponent,
String name,
T defaultValue)
Convenience method to get an optional attribute of type <T> from a component.
|
static boolean |
getBooleanAttribute(javax.faces.component.UIComponent uiComponent,
String name)
Convenience method to get a boolean attribute from a component.
|
static String |
getStringAttribute(javax.faces.component.UIComponent uiComponent,
String name)
Convenience method to get a String attribute from a component.
|
static <T extends javax.faces.validator.Validator> |
getValidator(javax.faces.component.UIInput component,
Class<T> type)
Gets the validator from the supplied input component that is of the supplied type T.
|
static boolean |
hasConverter(javax.faces.component.UIComponent component)
Determines whether the supplied component has an attached converter.
|
static boolean |
isComponentsContainerReadonly(javax.faces.component.UIComponent component)
Determines whether the container that contains the supplied component is readonly or not.
|
static boolean |
isComponentsFormReadonly(javax.faces.component.UIComponent component)
Determines whether the form that contains the supplied component is readonly or not.
|
static <T extends javax.faces.validator.Validator> |
removeValidators(javax.faces.component.UIInput component,
Class<T> type)
Removes all validators from the supplied input component that are of the supplied type T.
|
public static boolean isComponentsContainerReadonly(javax.faces.component.UIComponent component)
component - The component to check whether it is contained in a readonly container.NullPointerException - When the supplied component is null.public static boolean isComponentsFormReadonly(javax.faces.component.UIComponent component)
component - The component on the form, to check for being readonly.public static Object getAttribute(javax.faces.component.UIComponent uiComponent, String name)
<h:commandLink value="Submit" actionListener="#{demoBean.action}">
<f:attribute name="attributeName" value="attributeValue"/>
</h:commandLink>
In your bean you can use the following code snippet to access the attribute:
public void action(final ActionEvent actionEvent) {
final Object attributeValue = JsfComponentUtil.getAttribute(
actionEvent.getComponent(), "attributeName");
}
}uiComponent - The UIComponent containing the attribute.name - The name of the attribute.NullPointerException - When either the supplied uiComponent or name is null.IllegalArgumentException - When the supplied name is empty.public static boolean getBooleanAttribute(javax.faces.component.UIComponent uiComponent,
String name)
uiComponent - The UIComponent containing the boolean attribute.name - The name of the attribute.Boolean.parseBoolean(String) is used for parsing.NullPointerException - When either the supplied uiComponent or
name is null.IllegalArgumentException - When the supplied name is empty or when
the attribute is neither a String nor a Boolean.public static String getStringAttribute(javax.faces.component.UIComponent uiComponent, String name)
<h:commandLink value="Submit" actionListener="#{demoBean.action}">
<f:attribute name="attributeName" value="attributeValue"/>
</h:commandLink>
In your bean you can use the following code snippet to access the attribute:
public void action(final ActionEvent actionEvent) {
final String attributeValue = JsfComponentUtil.getStringAttribute(
actionEvent.getComponent(), "attributeName");
}uiComponent - The UIComponent containing the attribute.name - The name of the attribute.NullPointerException - When either the supplied uiComponent or name is null.IllegalArgumentException - When the supplied name is empty.public static <T> T getAttribute(javax.faces.component.UIComponent uiComponent,
String name,
T defaultValue)
<ice:selectInputText id="idScientistName" rows="5"
valueChangeListener="#{managedBean.updateAutoCompleteListener}" .../>
In your bean you can use code like the following to access the attribute:
public void updateAutoCompleteListener(final ValueChangeEvent valueChangeEvent) {
final Integer rows = getAttribute(valueChangeEvent.getComponent(),
"rows", Integer.valueOf(5));
...
}T - The type of the attribute to return.uiComponent - The UIComponent containing the attribute.name - The name of the attribute.defaultValue - The value to return when the attribute with the supplied name does not exist.ClassCastException - When the attribute with the supplied name is not of type <T>NullPointerException - When either the supplied uiComponent or name is null.IllegalArgumentException - When the supplied name is empty.public static boolean hasConverter(javax.faces.component.UIComponent component)
component - The component to check for a converter.public static <T extends javax.faces.validator.Validator> T getValidator(javax.faces.component.UIInput component,
Class<T> type)
T - The type of the validator to get.component - The component to get the validator from.type - The type of validator to get.NullPointerException - When either the supplied component or type is null.public static <T extends javax.faces.validator.Validator> int removeValidators(javax.faces.component.UIInput component,
Class<T> type)
T - The type of validator to remove.component - The component to remove the validators from.type - The type of validator to remove.NullPointerException - When either the supplied component or type is null.Copyright © 2008–2018. All rights reserved.