Class ComponentUtils
java.lang.Object
org.apache.myfaces.tobago.util.ComponentUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.faces.component.UIComponent
createComponent
(jakarta.faces.context.FacesContext facesContext, String componentType, RendererTypes rendererType, String clientId) static void
evaluateAutoFor
(jakarta.faces.component.UIComponent component, Class<? extends jakarta.faces.component.UIComponent> clazz) Looks for the attribute "for" of the component.static String
evaluateClientId
(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent component, String componentId) Resolves the real clientId.static String
evaluateClientIds
(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent component, String[] componentIds) Resolves the real clientIds.static <T> T
findAncestor
(jakarta.faces.component.UIComponent component, Class<T> type) static <T extends jakarta.faces.component.UIComponent>
TSearches the children beneath the component and return the first component matching the type.static String
findClientIdFor
(jakarta.faces.component.UIComponent component, jakarta.faces.context.FacesContext facesContext) Looks for the attribute "for" in the component.static jakarta.faces.component.UIComponent
findComponent
(jakarta.faces.component.UIComponent from, String relativeId) The search depends on the number of prefixed colons in the relativeId:static jakarta.faces.component.UIComponent
findComponent
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent from, String relativeId) The search depends on the number of prefixed colons in the relativeId:static <T extends jakarta.faces.component.UIComponent>
TfindDescendant
(jakarta.faces.component.UIComponent component, Class<T> type) Searches the component tree beneath the component and return the first component matching the type.static <T extends jakarta.faces.component.UIComponent>
List<T> findDescendantList
(jakarta.faces.component.UIComponent component, Class<T> type) Searches the component tree beneath the component and return all component matching the type.static <T extends jakarta.faces.component.UIComponent>
TfindFacetDescendant
(jakarta.faces.component.UIComponent component, Facets facet, Class<T> type) Searches the component tree beneath the component and return the first component matching the type.static jakarta.faces.component.UIComponent
findFor
(jakarta.faces.component.UIComponent component) static AbstractUIFormBase
findForm
(jakarta.faces.component.UIComponent component) static List
<jakarta.faces.component.UIComponent> findLayoutChildren
(jakarta.faces.component.UIComponent container) static AbstractUIPage
findPage
(jakarta.faces.component.UIComponent component) static AbstractUIPage
findPage
(jakarta.faces.context.FacesContext facesContext) static AbstractUIPage
findPage
(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent component) static Object
findParameter
(jakarta.faces.component.UIComponent component, String name) static List
<AbstractUIForm> findSubForms
(jakarta.faces.component.UIComponent component) Find all sub forms of a component, and collects it.static jakarta.faces.component.UIViewRoot
findViewRoot
(jakarta.faces.view.facelets.FaceletContext faceletContext, jakarta.faces.component.UIComponent component) Tries to walk up the parents to find the UIViewRoot, if not found, then go to FaceletContext's FacesContext for the view root.static Object
getAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static boolean
getBooleanAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static boolean
getBooleanAttribute
(jakarta.faces.component.UIComponent component, Attributes name, boolean defaultValue) static Character
getCharacterAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static String
getConfirmation
(jakarta.faces.component.UIComponent component) returns the "confirmation" attribute or the value of the "confirmation" facet of a component.static Object
getConvertedValue
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component, String stringValue) static jakarta.faces.convert.Converter
getConverter
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component, Object value) Deprecated, for removal: This API element is subject to removal in a future version.static Object
getDataAttribute
(jakarta.faces.component.UIComponent component, String name) getDataAttributes
(jakarta.faces.component.UIComponent component) static String
getFacesMessageAsString
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component) static jakarta.faces.component.UIComponent
static String
getFormattedValue
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component, Object currentValue) Deprecated, for removal: This API element is subject to removal in a future version.static int
getIntAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static int
getIntAttribute
(jakarta.faces.component.UIComponent component, Attributes name, int defaultValue) static jakarta.faces.application.FacesMessage.Severity
getMaximumSeverity
(jakarta.faces.component.UIComponent component) static jakarta.faces.application.FacesMessage.Severity
getMaximumSeverity
(List<jakarta.faces.application.FacesMessage> messages) static jakarta.faces.application.FacesMessage.Severity
getMaximumSeverityOfChildrenMessages
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.NamingContainer container) static AbstractUIReload
getReloadFacet
(jakarta.faces.component.UIComponent component) static RendererBase
getRenderer
(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component) static RendererBase
getRenderer
(jakarta.faces.context.FacesContext facesContext, String family, String rendererType) static String
getStringAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static String
getStringAttribute
(jakarta.faces.component.UIComponent component, Attributes name, String defaultValue) static boolean
hasErrorMessages
(jakarta.faces.context.FacesContext context) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isError
(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isError
(jakarta.faces.component.UIInput uiInput) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isFacetOf
(jakarta.faces.component.UIComponent component, jakarta.faces.component.UIComponent parent) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isInActiveForm
(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isInPopup
(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isOutputOnly
(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version.static boolean
isStandardHtmlRendererType
(jakarta.faces.component.UIComponent component) static Markup
markupOfSeverity
(jakarta.faces.application.FacesMessage.Severity maximumSeverity) static void
putDataAttribute
(jakarta.faces.component.UIComponent component, Object name, Object value) Adding a data attribute to the component.static void
putDataAttributeWithPrefix
(jakarta.faces.component.UIComponent component, DataAttributes name, Object value) Adding a data attribute to the component.static void
removeAttribute
(jakarta.faces.component.UIComponent component, Attributes name) static void
removeFacet
(jakarta.faces.component.UIComponent component, Facets facet) static void
resetPage
(jakarta.faces.context.FacesContext context) Deprecated, for removal: This API element is subject to removal in a future version.static void
setAttribute
(jakarta.faces.component.UIComponent component, Attributes name, Object value) static void
setFacet
(jakarta.faces.component.UIComponent component, Facets facet, jakarta.faces.component.UIComponent child) static String[]
-
Field Details
-
SUB_SEPARATOR
- See Also:
-
ACTION_ARGS
-
ACTION_LISTENER_ARGS
-
VALUE_CHANGE_LISTENER_ARGS
-
VALIDATOR_ARGS
-
LIST_SEPARATOR_CHARS
- See Also:
-
SET_SKIP_UNRENDERED
-
DATA_ATTRIBUTES_KEY
Name of the map for data attributes in components. New in JSF 2.2.- Since:
- 2.0.0
- See Also:
-
-
Method Details
-
isStandardHtmlRendererType
public static boolean isStandardHtmlRendererType(jakarta.faces.component.UIComponent component) -
hasErrorMessages
@Deprecated(since="3.0.1", forRemoval=true) public static boolean hasErrorMessages(jakarta.faces.context.FacesContext context) Deprecated, for removal: This API element is subject to removal in a future version. -
getFacesMessageAsString
public static String getFacesMessageAsString(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component) -
isInPopup
@Deprecated(since="3.0.1", forRemoval=true) public static boolean isInPopup(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version. -
resetPage
@Deprecated(since="3.0.1", forRemoval=true) public static void resetPage(jakarta.faces.context.FacesContext context) Deprecated, for removal: This API element is subject to removal in a future version. -
findViewRoot
public static jakarta.faces.component.UIViewRoot findViewRoot(jakarta.faces.view.facelets.FaceletContext faceletContext, jakarta.faces.component.UIComponent component) Tries to walk up the parents to find the UIViewRoot, if not found, then go to FaceletContext's FacesContext for the view root. -
findPage
public static AbstractUIPage findPage(jakarta.faces.context.FacesContext context, jakarta.faces.component.UIComponent component) -
findPage
-
findPage
-
findForm
-
findAncestor
-
findSubForms
Find all sub forms of a component, and collects it. It does not find sub forms of sub forms. -
findDescendant
public static <T extends jakarta.faces.component.UIComponent> T findDescendant(jakarta.faces.component.UIComponent component, Class<T> type) Searches the component tree beneath the component and return the first component matching the type. -
findFacetDescendant
-
findChild
public static <T extends jakarta.faces.component.UIComponent> T findChild(jakarta.faces.component.UIComponent component, Class<T> type) Searches the children beneath the component and return the first component matching the type. -
findDescendantList
-
findClientIdFor
public static String findClientIdFor(jakarta.faces.component.UIComponent component, jakarta.faces.context.FacesContext facesContext) Looks for the attribute "for" in the component. If there is any search for the component which is referenced by the "for" attribute, and return their clientId. If there is no "for" attribute, return the "clientId" of the parent (if it has a parent). This is useful for labels. -
findFor
public static jakarta.faces.component.UIComponent findFor(jakarta.faces.component.UIComponent component) -
evaluateAutoFor
public static void evaluateAutoFor(jakarta.faces.component.UIComponent component, Class<? extends jakarta.faces.component.UIComponent> clazz) Looks for the attribute "for" of the component. In case that the value is equals to "@auto" the children of the parent will be checked if they are of the type of the parameter clazz. The "id" of the first one will be used to reset the "for" attribute of the component. -
isInActiveForm
@Deprecated(since="4.0.0", forRemoval=true) public static boolean isInActiveForm(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version. -
getMaximumSeverity
public static jakarta.faces.application.FacesMessage.Severity getMaximumSeverity(jakarta.faces.component.UIComponent component) -
getMaximumSeverity
public static jakarta.faces.application.FacesMessage.Severity getMaximumSeverity(List<jakarta.faces.application.FacesMessage> messages) -
isError
@Deprecated(since="5.0.0", forRemoval=true) public static boolean isError(jakarta.faces.component.UIInput uiInput) Deprecated, for removal: This API element is subject to removal in a future version. -
isError
@Deprecated(since="5.0.0", forRemoval=true) public static boolean isError(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version. -
isOutputOnly
@Deprecated(since="5.0.0", forRemoval=true) public static boolean isOutputOnly(jakarta.faces.component.UIComponent component) Deprecated, for removal: This API element is subject to removal in a future version. -
getAttribute
-
getBooleanAttribute
public static boolean getBooleanAttribute(jakarta.faces.component.UIComponent component, Attributes name) -
getBooleanAttribute
public static boolean getBooleanAttribute(jakarta.faces.component.UIComponent component, Attributes name, boolean defaultValue) -
getStringAttribute
public static String getStringAttribute(jakarta.faces.component.UIComponent component, Attributes name) -
getStringAttribute
public static String getStringAttribute(jakarta.faces.component.UIComponent component, Attributes name, String defaultValue) -
getIntAttribute
-
getIntAttribute
public static int getIntAttribute(jakarta.faces.component.UIComponent component, Attributes name, int defaultValue) -
getCharacterAttribute
public static Character getCharacterAttribute(jakarta.faces.component.UIComponent component, Attributes name) -
setAttribute
public static void setAttribute(jakarta.faces.component.UIComponent component, Attributes name, Object value) -
removeAttribute
-
getFacet
public static jakarta.faces.component.UIComponent getFacet(jakarta.faces.component.UIComponent component, Facets facet) -
setFacet
public static void setFacet(jakarta.faces.component.UIComponent component, Facets facet, jakarta.faces.component.UIComponent child) -
removeFacet
-
getReloadFacet
-
isFacetOf
@Deprecated(since="5.0.0", forRemoval=true) public static boolean isFacetOf(jakarta.faces.component.UIComponent component, jakarta.faces.component.UIComponent parent) Deprecated, for removal: This API element is subject to removal in a future version. -
getRenderer
public static RendererBase getRenderer(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component) -
getRenderer
public static RendererBase getRenderer(jakarta.faces.context.FacesContext facesContext, String family, String rendererType) -
findParameter
-
findComponent
public static jakarta.faces.component.UIComponent findComponent(jakarta.faces.component.UIComponent from, String relativeId) The search depends on the number of prefixed colons in the relativeId:
- number of prefixed colons == 0
- fully relative
- number of prefixed colons == 1
- absolute (still normal findComponent syntax)
- number of prefixed colons == 2
- search in the current naming container (same as 0 colons)
- number of prefixed colons == 3
- search in the parent naming container of the current naming container
- number of prefixed colons > 3
- go to the next parent naming container for each additional colon
If a literal is specified: to use more than one identifier the identifiers must be space delimited.
-
findComponent
public static jakarta.faces.component.UIComponent findComponent(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent from, String relativeId) The search depends on the number of prefixed colons in the relativeId:
- number of prefixed colons == 0
- fully relative
- number of prefixed colons == 1
- absolute (still normal findComponent syntax)
- number of prefixed colons == 2
- search in the current naming container (same as 0 colons)
- number of prefixed colons == 3
- search in the parent naming container of the current naming container
- number of prefixed colons > 3
- go to the next parent naming container for each additional colon
If a literal is specified: to use more than one identifier the identifiers must be space delimited.
-
evaluateClientIds
-
evaluateClientId
-
splitList
-
getConvertedValue
-
markupOfSeverity
public static Markup markupOfSeverity(jakarta.faces.application.FacesMessage.Severity maximumSeverity) -
getMaximumSeverityOfChildrenMessages
public static jakarta.faces.application.FacesMessage.Severity getMaximumSeverityOfChildrenMessages(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.NamingContainer container) -
putDataAttributeWithPrefix
public static void putDataAttributeWithPrefix(jakarta.faces.component.UIComponent component, DataAttributes name, Object value) Adding a data attribute to the component. The name must start with "data-", e. g. "data-tobago-foo" or "data-bar" -
putDataAttribute
-
getDataAttributes
-
getDataAttribute
-
getConverter
@Deprecated(since="5.0.0", forRemoval=true) public static jakarta.faces.convert.Converter getConverter(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component, Object value) Deprecated, for removal: This API element is subject to removal in a future version.May return null, if no converter can be find. -
getFormattedValue
@Deprecated(since="5.0.0", forRemoval=true) public static String getFormattedValue(jakarta.faces.context.FacesContext facesContext, jakarta.faces.component.UIComponent component, Object currentValue) throws jakarta.faces.convert.ConverterException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
jakarta.faces.convert.ConverterException
-
createComponent
public static jakarta.faces.component.UIComponent createComponent(jakarta.faces.context.FacesContext facesContext, String componentType, RendererTypes rendererType, String clientId) -
findLayoutChildren
public static List<jakarta.faces.component.UIComponent> findLayoutChildren(jakarta.faces.component.UIComponent container) -
getConfirmation
returns the "confirmation" attribute or the value of the "confirmation" facet of a component.- Since:
- Tobago 4.4.0
-
RendererBase.getConverter(jakarta.faces.context.FacesContext, T, java.lang.Object)
.