Package org.primefaces.util
Class ResourceUtils
java.lang.Object
org.primefaces.util.ResourceUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddComponentResource(javax.faces.context.FacesContext context, String name) static voidaddComponentResource(javax.faces.context.FacesContext context, String name, String library) static voidaddComponentResource(javax.faces.context.FacesContext context, String name, String library, String target) static voidaddNoCacheControl(javax.faces.context.ExternalContext externalContext) Adds no cache pragma to the response to ensure it is not cached.static voidaddResponseCookie(javax.faces.context.FacesContext context, String name, String value, Map<String, Object> properties) Adds the cookie represented by the arguments to the response.static StringappendCacheBuster(String url, boolean cache) static StringencodeResourceURL(javax.faces.context.FacesContext context, String src, boolean cache) static javax.faces.application.ResourceevaluateResourceExpression(javax.faces.context.FacesContext facesContext, javax.el.ValueExpression valueExpression) Per default the JSF implementation evaluates resource expressions as String and returnsResource.getRequestPath().static List<ResourceUtils.ResourceInfo>getComponentResources(javax.faces.context.FacesContext context) static StringgetMonitorKeyCookieName(javax.faces.context.FacesContext context, javax.el.ValueExpression monitorKey) static StringgetResourceRequestPath(javax.faces.context.FacesContext context, String resourceName) static StringgetResourceURL(javax.faces.context.FacesContext context, String value) static booleanisInline(ResourceUtils.ResourceInfo resourceInfo) static booleanisResourceNotFound(javax.faces.application.Resource resource) static booleanisScript(javax.faces.component.UIComponent component) static booleanisStylesheet(javax.faces.component.UIComponent component) static javax.faces.application.ResourcenewResource(ResourceUtils.ResourceInfo resourceInfo, javax.faces.context.FacesContext context) static ResourceUtils.ResourceInfonewResourceInfo(javax.faces.component.UIComponent component) static StringtoBase64(javax.faces.context.FacesContext context, byte[] bytes) static Stringstatic StringtoBase64(javax.faces.context.FacesContext context, InputStream is) static StringtoBase64(javax.faces.context.FacesContext context, InputStream is, String contentType) static StringtoBase64(javax.faces.context.FacesContext context, Consumer<OutputStream> writer, String contentType) static StringtoBase64(javax.faces.context.FacesContext context, javax.faces.application.Resource resource) static byte[]static byte[]
-
Field Details
-
RENDERER_SCRIPT
- See Also:
-
RENDERER_STYLESHEET
- See Also:
-
RES_NOT_FOUND
- See Also:
-
-
Method Details
-
getResourceURL
-
encodeResourceURL
-
toBase64
public static String toBase64(javax.faces.context.FacesContext context, javax.faces.application.Resource resource) -
toBase64
-
toBase64
public static String toBase64(javax.faces.context.FacesContext context, Consumer<OutputStream> writer, String contentType) -
toBase64
public static String toBase64(javax.faces.context.FacesContext context, InputStream is, String contentType) -
toBase64
-
toBase64
-
toByteArray
-
toByteArray
-
addNoCacheControl
public static void addNoCacheControl(javax.faces.context.ExternalContext externalContext) Adds no cache pragma to the response to ensure it is not cached. Dynamic downloads should always add this to prevent caching and for GDPR.- Parameters:
externalContext- the ExternalContext we add the pragma to- See Also:
-
addResponseCookie
public static void addResponseCookie(javax.faces.context.FacesContext context, String name, String value, Map<String, Object> properties) Adds the cookie represented by the arguments to the response. If the current HTTP conversation is secured over SSL (e.g. https:) then the cookie is set to secure=true and sameSite=Strict.- Parameters:
context- the FacesContext contains the External context we add the cookie toname- To be passed as the first argument to theCookieconstructor.value- To be passed as the second argument to theCookieconstructor.properties- AMapcontaining key/value pairs to be passed as arguments to the setter methods as described above.
-
appendCacheBuster
-
getResourceRequestPath
-
addComponentResource
-
addComponentResource
-
addComponentResource
-
isScript
public static boolean isScript(javax.faces.component.UIComponent component) -
isStylesheet
public static boolean isStylesheet(javax.faces.component.UIComponent component) -
getComponentResources
public static List<ResourceUtils.ResourceInfo> getComponentResources(javax.faces.context.FacesContext context) -
isInline
-
newResourceInfo
public static ResourceUtils.ResourceInfo newResourceInfo(javax.faces.component.UIComponent component) -
newResource
public static javax.faces.application.Resource newResource(ResourceUtils.ResourceInfo resourceInfo, javax.faces.context.FacesContext context) -
getMonitorKeyCookieName
public static String getMonitorKeyCookieName(javax.faces.context.FacesContext context, javax.el.ValueExpression monitorKey) -
isResourceNotFound
public static boolean isResourceNotFound(javax.faces.application.Resource resource) -
evaluateResourceExpression
public static javax.faces.application.Resource evaluateResourceExpression(javax.faces.context.FacesContext facesContext, javax.el.ValueExpression valueExpression) Per default the JSF implementation evaluates resource expressions as String and returnsResource.getRequestPath(). This method resolves the expression to theResourceitself.- Parameters:
facesContext- TheFacesContextvalueExpression- TheValueExpression- Returns:
- Null if the valueExpression is not of the form #{resource['path/to/resource']} or #{resource['library:name']}.
Otherwise the value obtained by
ResourceHandler.createResource(java.lang.String).
-