Package org.primefaces.util
Class ComponentUtils
java.lang.Object
org.primefaces.util.ComponentUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcalculateViewId(javax.faces.context.FacesContext context) Calculates the current viewId - we can't get it from the ViewRoot if it's not available.static <T> TcomputeIfAbsent(javax.faces.component.StateHelper stateHelper, Serializable key, Supplier<T> defaultValueSupplier) Tries to retrieve value from stateHelper by key first.static StringcreateContentDisposition(String value, String filename) Creates an RFC 6266 Content-Dispostion header following all UTF-8 conventions.static voiddecodeBehaviors(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) static StringencodeComponent(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) Encodes the given component locally as HTML.static voidencodeIndexedId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, int index) GitHub #7763 Renders an in memory UIComponent and updates its ID with an index.static StringDuplicate code from OmniFacew project under apache license: https://github.com/omnifaces/omnifaces/blob/develop/license.txtstatic StringescapeSelector(String selector) static <T> Teval(javax.faces.component.StateHelper stateHelper, Serializable key, Supplier<T> defaultValueSupplier) Tries to retrieve value from stateHelper by key first.static <T> TexecuteInRequestScope(javax.faces.context.FacesContext context, String var, Object value, Supplier<T> callback) static javax.faces.application.NavigationCasefindNavigationCase(javax.faces.context.FacesContext context, String outcome) static StringgetConvertedAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) static StringgetConvertedAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object converter, Object value) static ObjectgetConvertedValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) static ObjectgetConvertedValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object converter, Object value) static javax.faces.convert.ConvertergetConverter(javax.faces.context.FacesContext context, Class<?> forClass) static javax.faces.convert.ConvertergetConverter(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) Finds appropriate converter for a given value holderstatic ObjectgetDynamicColumnValue(javax.faces.component.UIComponent component) static StringgetDynamicColumnValueAsString(javax.faces.component.UIComponent component) static ObjectgetLabel(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component) static intgetRenderedChildCount(javax.faces.component.UIComponent component) getUIParams(javax.faces.component.UIComponent component) static <T extends javax.faces.render.Renderer>
TgetUnwrappedRenderer(javax.faces.context.FacesContext context, String family, String rendererType) static StringgetValueToRender(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) static StringgetValueToRender(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) Algorithm works as follows; - If it's an input component, submitted value is checked first since it'd be the value to be used in case validation errors terminates jsf lifecycle - Finally the value of the component is retrieved from backing bean and if there's a converter, converted value is returnedstatic booleanisDisabledOrReadonly(javax.faces.component.UIInput component) static booleanstatic booleanisNestedWithinIterator(javax.faces.component.UIComponent component) Hack for Mojarra as our UIData is copied from Mojarra.static booleanisRequestSource(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) static booleanisRequestSource(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context, String event) static booleanstatic booleanisSkipIteration(javax.faces.component.visit.VisitContext visitContext, javax.faces.context.FacesContext context) static booleanisTouchable(javax.faces.context.FacesContext context, TouchAware component) static booleanisUIRepeat(javax.faces.component.UIComponent component) isViewPooling(javax.faces.context.FacesContext context) static voidprocessDecodesOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) static voidprocessUpdatesOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) static voidprocessValidatorsOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) static booleanshouldRenderChildren(javax.faces.component.UIComponent component) Checks if the component's children are renderedstatic booleanshouldRenderFacet(javax.faces.component.UIComponent facet) Checks if the facet and one of the first level children is rendered.static booleanshouldRenderFacet(javax.faces.component.UIComponent facet, boolean alwaysRender) Checks if the facet and one of the first level children is rendered.static javax.faces.convert.ConvertertoConverter(javax.faces.context.FacesContext context, Object object)
-
Field Details
-
VISIT_HINTS_SKIP_UNRENDERED
-
VISIT_HINTS_SKIP_ITERATION
-
SKIP_ITERATION_HINT
- See Also:
-
-
Method Details
-
getValueToRender
public static String getValueToRender(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) -
getValueToRender
public static String getValueToRender(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) Algorithm works as follows; - If it's an input component, submitted value is checked first since it'd be the value to be used in case validation errors terminates jsf lifecycle - Finally the value of the component is retrieved from backing bean and if there's a converter, converted value is returned- Parameters:
context- FacesContext instancecomponent- UIComponent instance whose value will be returnedvalue- The value of UIComponent if already evaluated outside. E.g. in the renderer.- Returns:
- End text
-
getConverter
public static javax.faces.convert.Converter getConverter(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) Finds appropriate converter for a given value holder- Parameters:
context- FacesContext instancecomponent- ValueHolder instance to look up converter for- Returns:
- Converter
-
getConvertedValue
-
getConvertedValue
-
getConvertedAsString
-
getConvertedAsString
-
getConverter
public static javax.faces.convert.Converter getConverter(javax.faces.context.FacesContext context, Class<?> forClass) -
toConverter
public static javax.faces.convert.Converter toConverter(javax.faces.context.FacesContext context, Object object) -
decodeBehaviors
public static void decodeBehaviors(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) -
escapeSelector
-
isRTL
-
isTouchable
-
isFlex
-
processDecodesOfFacetsAndChilds
public static void processDecodesOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) -
processValidatorsOfFacetsAndChilds
public static void processValidatorsOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) -
processUpdatesOfFacetsAndChilds
public static void processUpdatesOfFacetsAndChilds(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) -
getUIParams
-
isSkipIteration
public static boolean isSkipIteration(javax.faces.component.visit.VisitContext visitContext, javax.faces.context.FacesContext context) -
getUnwrappedRenderer
-
calculateViewId
Calculates the current viewId - we can't get it from the ViewRoot if it's not available.- Parameters:
context- TheFacesContext.- Returns:
- The current viewId.
-
encodeURI
Duplicate code from OmniFacew project under apache license: https://github.com/omnifaces/omnifaces/blob/develop/license.txtURI-encode the given string using UTF-8. URIs (paths and filenames) have different encoding rules as compared to URL query string parameters.
URLEncoderis actually only for www (HTML) form based query string parameter values (as used when a webbrowser submits a HTML form). URI encoding has a lot in common with URL encoding, but the space has to be %20 and some chars doesn't necessarily need to be encoded.- Parameters:
string- The string to be URI-encoded using UTF-8.- Returns:
- The given string, URI-encoded using UTF-8, or
nullifnullwas given. - Throws:
UnsupportedEncodingException- if UTF-8 is not supported
-
createContentDisposition
Creates an RFC 6266 Content-Dispostion header following all UTF-8 conventions.- Parameters:
value- e.g. "attachment"filename- the name of the file- Returns:
- a valid Content-Disposition header in UTF-8 format
-
isRequestSource
public static boolean isRequestSource(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) -
isRequestSource
public static boolean isRequestSource(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context, String event) -
getLabel
public static Object getLabel(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component) -
shouldRenderFacet
public static boolean shouldRenderFacet(javax.faces.component.UIComponent facet, boolean alwaysRender) Checks if the facet and one of the first level children is rendered.- Parameters:
facet- The Facet component to checkalwaysRender- flag to ignore children and only check the facet itself- Returns:
- true if the facet should be rendered, false if not
-
shouldRenderFacet
public static boolean shouldRenderFacet(javax.faces.component.UIComponent facet) Checks if the facet and one of the first level children is rendered.- Parameters:
facet- The Facet component to check- Returns:
- true when facet and one of the first level children is rendered.
-
shouldRenderChildren
public static boolean shouldRenderChildren(javax.faces.component.UIComponent component) Checks if the component's children are rendered- Parameters:
component- The component to check- Returns:
- true if one of the first level child's is rendered.
-
eval
public static <T> T eval(javax.faces.component.StateHelper stateHelper, Serializable key, Supplier<T> defaultValueSupplier) Tries to retrieve value from stateHelper by key first. If the value is not present (or is null), then it is retrieved from defaultValueSupplier. Should be removed whenStateHelperis extended with similar functionality. (see https://github.com/eclipse-ee4j/mojarra/issues/4568 for details)- Type Parameters:
T- the expected type of returned value- Parameters:
stateHelper- The stateHelper to try to retrieve value fromkey- The key under which value is stored in the stateHelperdefaultValueSupplier- The object, from which default value is retrieved- Returns:
- value from stateHelper or defaultValueSupplier
-
computeIfAbsent
public static <T> T computeIfAbsent(javax.faces.component.StateHelper stateHelper, Serializable key, Supplier<T> defaultValueSupplier) Tries to retrieve value from stateHelper by key first. If the value is not present (or is null), then it is retrieved from defaultValueSupplier. Should be removed whenStateHelperis extended with similar functionality. (see https://github.com/eclipse-ee4j/mojarra/issues/4568 for details)- Type Parameters:
T- the expected type of returned value- Parameters:
stateHelper- The stateHelper to try to retrieve value fromkey- The key under which value is stored in the stateHelperdefaultValueSupplier- The object, from which default value is retrieved- Returns:
- value from stateHelper or defaultValueSupplier
-
isViewPooling
public static ComponentUtils.ViewPoolingResetMode isViewPooling(javax.faces.context.FacesContext context) -
isNestedWithinIterator
public static boolean isNestedWithinIterator(javax.faces.component.UIComponent component) Hack for Mojarra as our UIData is copied from Mojarra. This is required because the way how UIData is implemented in Mojarra requires to check for parent iterator-components.- Parameters:
component-- Returns:
-
encodeIndexedId
public static void encodeIndexedId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, int index) throws IOException GitHub #7763 Renders an in memory UIComponent and updates its ID with an index. For example id="form:test" becomes id="form:test:0".- Parameters:
context- theFacesContext.component- theUIComponentto render.index- the index number to append to the ID- Throws:
IOException- if any IO error occurs
-
getDynamicColumnValue
-
getDynamicColumnValueAsString
-
encodeComponent
public static String encodeComponent(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context) Encodes the given component locally as HTML.- Parameters:
component- The component to capture HTML output for.context- The current FacesContext.- Returns:
- The encoded HTML output of the given component.
- Throws:
UncheckedIOException- Whenever something fails at I/O level. This would be quite unexpected as it happens locally.
-
executeInRequestScope
-
getRenderedChildCount
public static int getRenderedChildCount(javax.faces.component.UIComponent component) -
isDisabledOrReadonly
public static boolean isDisabledOrReadonly(javax.faces.component.UIInput component) -
isUIRepeat
public static boolean isUIRepeat(javax.faces.component.UIComponent component)
-