- java.lang.Object
-
- org.omnifaces.util.Hacks
-
public final class Hacks extends Object
Collection of Faces implementation and/or Faces component library and/or server specific hacks.
This class is not listed in showcase! Should I use it?
This class is indeed intended for internal usage only. We won't add methods here on user request. We only add methods here once we encounter non-DRY code in OmniFaces codebase. The methods may be renamed/changed without notice.
We don't stop you from using it if you found it in the Javadoc and you think you find it useful, but you have to accept the risk that the method signatures can be changed without notice. This utility class exists because OmniFaces intends to be free of 3rd party dependencies.
- Since:
- 1.3
- Author:
- Bauke Scholtz, Arjan Tijms
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearCachedFacesServletMapping(FacesContext context)
Clear the cached faces servlet mapping as interpreted by either Mojarra or MyFaces.static VariableMapper
findWrappedVariableMapper(VariableMapper mapper)
Finds the wrapped variable mapper of the given variable mapper.static long
getDefaultResourceMaxAge()
Returns the default resource maximum age in milliseconds.static UIComponent
getMetadataFacet(UIViewRoot viewRoot)
Returns f:metadata facet from UIViewRoot.static StateHelper
getStateHelper(UIComponent component)
Expose protected state helper into public.static boolean
isFacesScriptResourceAvailable()
Returnstrue
ifjakarta.faces:faces.js
script resource is available.static boolean
isMojarraUsed()
Returns true if Mojarra is used.static boolean
isMyFacesUsed()
Returns true if MyFaces is used.static boolean
isNestedInPrimeFacesDialog(UIComponent... components)
Returns true if the given components are nested in (same) PrimeFaces dialog.static boolean
isPrimeFacesAjaxRequest(FacesContext context)
Returns true if the current request is a PrimeFaces ajax request.static boolean
isPrimeFacesDynamicResourceRequest(FacesContext context)
Returns true if the current request is a PrimeFaces dynamic resource request.static boolean
isTomcatWebSocketBombed(Session session, IllegalStateException illegalStateException)
Returns true if the given WS session is from Tomcat and given illegal state exception is caused by a push bomb which Tomcat couldn't handle.static void
removeResourceDependencyState(FacesContext context)
Remove the resource dependency processing related attributes from the given faces context.static void
removeViewState(FacesContext context, ResponseStateManager manager, String viewId)
Remove server side Faces view state (and view scoped beans) associated with current request.static void
setComponentResourceUniqueId(FacesContext context, UIComponent resource)
Set the unique ID of the component resource, taking into account MyFaces-specific way of generating a resource specific unique ID.
-
-
-
Method Detail
-
isMojarraUsed
public static boolean isMojarraUsed()
Returns true if Mojarra is used. That is, when the FacesContext instance is from the Mojarra specific package.- Returns:
- Whether Mojarra is used.
- Since:
- 3.9
-
isMyFacesUsed
public static boolean isMyFacesUsed()
Returns true if MyFaces is used. That is, when the FacesContext instance is from the MyFaces specific package.- Returns:
- Whether MyFaces is used.
- Since:
- 1.8
-
getDefaultResourceMaxAge
public static long getDefaultResourceMaxAge()
Returns the default resource maximum age in milliseconds.- Returns:
- The default resource maximum age in milliseconds.
-
removeResourceDependencyState
public static void removeResourceDependencyState(FacesContext context)
Remove the resource dependency processing related attributes from the given faces context.- Parameters:
context
- The involved faces context.
-
setComponentResourceUniqueId
public static void setComponentResourceUniqueId(FacesContext context, UIComponent resource)
Set the unique ID of the component resource, taking into account MyFaces-specific way of generating a resource specific unique ID.- Parameters:
context
- The involved faces context.resource
- The involved component resource.- Since:
- 2.6.1
-
clearCachedFacesServletMapping
public static void clearCachedFacesServletMapping(FacesContext context)
Clear the cached faces servlet mapping as interpreted by either Mojarra or MyFaces. This is useful if you want to force the impl to recalculate the faces servlet mapping.- Parameters:
context
- The involved faces context.- Since:
- 3.10
-
isFacesScriptResourceAvailable
public static boolean isFacesScriptResourceAvailable()
Returnstrue
ifjakarta.faces:faces.js
script resource is available.- Returns:
true
ifjakarta.faces:faces.js
script resource is available.- Since:
- 4.0
-
removeViewState
public static void removeViewState(FacesContext context, ResponseStateManager manager, String viewId)
Remove server side Faces view state (and view scoped beans) associated with current request.- Parameters:
context
- The involved faces context.manager
- The involved response state manager.viewId
- The view ID of the involved view.- Since:
- 2.3
-
getStateHelper
public static StateHelper getStateHelper(UIComponent component)
Expose protected state helper into public.- Parameters:
component
- The component to obtain state helper for.- Returns:
- The state helper of the given component.
- Since:
- 2.3
-
getMetadataFacet
public static UIComponent getMetadataFacet(UIViewRoot viewRoot)
Returns f:metadata facet from UIViewRoot. MyFaces 3.x unexpectedly doesn't useUIViewRoot.METADATA_FACET_NAME
anymore to identify the facet.- Parameters:
viewRoot
- The UIViewRoot to obtain f:metadata facet from.- Returns:
- f:metadata facet from UIViewRoot.
- Since:
- 4.0
-
findWrappedVariableMapper
public static VariableMapper findWrappedVariableMapper(VariableMapper mapper)
Finds the wrapped variable mapper of the given variable mapper.- Parameters:
mapper
- The variable mapper to find wrapped variable mapper for.- Returns:
- The wrapped variable mapper of the given variable mapper.
- Since:
- 3.14.4
-
isPrimeFacesDynamicResourceRequest
public static boolean isPrimeFacesDynamicResourceRequest(FacesContext context)
Returns true if the current request is a PrimeFaces dynamic resource request.- Parameters:
context
- The involved faces context.- Returns:
- Whether the current request is a PrimeFaces dynamic resource request.
- Since:
- 1.8
-
isPrimeFacesAjaxRequest
public static boolean isPrimeFacesAjaxRequest(FacesContext context)
Returns true if the current request is a PrimeFaces ajax request.- Parameters:
context
- The involved faces context.- Returns:
- Whether the current request is a PrimeFaces ajax request.
- Since:
- 2.7.12
-
isNestedInPrimeFacesDialog
public static boolean isNestedInPrimeFacesDialog(UIComponent... components)
Returns true if the given components are nested in (same) PrimeFaces dialog.- Parameters:
components
- The components to be checked.- Returns:
- Whether the given components are nested in (same) PrimeFaces dialog.
- Since:
- 2.6
-
isTomcatWebSocketBombed
public static boolean isTomcatWebSocketBombed(Session session, IllegalStateException illegalStateException)
Returns true if the given WS session is from Tomcat and given illegal state exception is caused by a push bomb which Tomcat couldn't handle. See also https://bz.apache.org/bugzilla/show_bug.cgi?id=56026 and https://github.com/omnifaces/omnifaces/issues/234- Parameters:
session
- The WS session.illegalStateException
- The illegal state exception.- Returns:
- Whether it was Tomcat who couldn't handle the push bomb.
- Since:
- 2.5
-
-