Package org.primefaces.util
Class ResourceUtils
- java.lang.Object
-
- org.primefaces.util.ResourceUtils
-
public class ResourceUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceUtils.ResourceInfo
-
Field Summary
Fields Modifier and Type Field Description static String
RENDERER_SCRIPT
static String
RENDERER_STYLESHEET
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addComponentResource(javax.faces.context.FacesContext context, String name)
static void
addComponentResource(javax.faces.context.FacesContext context, String name, String library)
static void
addComponentResource(javax.faces.context.FacesContext context, String name, String library, String target)
static void
addNoCacheControl(javax.faces.context.ExternalContext externalContext)
Adds no cache pragma to the response to ensure it is not cached.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.static String
appendCacheBuster(String url, boolean cache)
static String
encodeResourceURL(javax.faces.context.FacesContext context, String src, boolean cache)
static List<ResourceUtils.ResourceInfo>
getComponentResources(javax.faces.context.FacesContext context)
static String
getMonitorKeyCookieName(javax.faces.context.FacesContext context, javax.el.ValueExpression monitorKey)
static String
getResourceRequestPath(javax.faces.context.FacesContext context, String resourceName)
static String
getResourceURL(javax.faces.context.FacesContext context, String value)
static boolean
isInline(ResourceUtils.ResourceInfo resourceInfo)
static boolean
isScript(javax.faces.component.UIComponent component)
static boolean
isStylesheet(javax.faces.component.UIComponent component)
static javax.faces.application.Resource
newResource(ResourceUtils.ResourceInfo resourceInfo, javax.faces.context.FacesContext context)
static ResourceUtils.ResourceInfo
newResourceInfo(javax.faces.component.UIComponent component)
static String
toBase64(javax.faces.context.FacesContext context, byte[] bytes)
static String
toBase64(javax.faces.context.FacesContext context, byte[] bytes, String contentType)
static String
toBase64(javax.faces.context.FacesContext context, InputStream is)
static String
toBase64(javax.faces.context.FacesContext context, InputStream is, String contentType)
static String
toBase64(javax.faces.context.FacesContext context, Consumer<OutputStream> writer, String contentType)
static String
toBase64(javax.faces.context.FacesContext context, javax.faces.application.Resource resource)
static byte[]
toByteArray(InputStream is)
static byte[]
toByteArray(Consumer<OutputStream> os)
-
-
-
Field Detail
-
RENDERER_SCRIPT
public static final String RENDERER_SCRIPT
- See Also:
- Constant Field Values
-
RENDERER_STYLESHEET
public static final String RENDERER_STYLESHEET
- See Also:
- Constant Field Values
-
-
Method Detail
-
getResourceURL
public static String getResourceURL(javax.faces.context.FacesContext context, String value)
-
encodeResourceURL
public static String encodeResourceURL(javax.faces.context.FacesContext context, String src, boolean cache)
-
toBase64
public static String toBase64(javax.faces.context.FacesContext context, javax.faces.application.Resource resource)
-
toBase64
public static String toBase64(javax.faces.context.FacesContext context, InputStream is)
-
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
public static String toBase64(javax.faces.context.FacesContext context, byte[] bytes)
-
toBase64
public static String toBase64(javax.faces.context.FacesContext context, byte[] bytes, String contentType)
-
toByteArray
public static byte[] toByteArray(Consumer<OutputStream> os)
-
toByteArray
public static byte[] toByteArray(InputStream is)
-
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:
- FileDownload: configure Cache-Control
-
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 theCookie
constructor.value
- To be passed as the second argument to theCookie
constructor.properties
- AMap
containing key/value pairs to be passed as arguments to the setter methods as described above.
-
getResourceRequestPath
public static String getResourceRequestPath(javax.faces.context.FacesContext context, String resourceName)
-
addComponentResource
public static void addComponentResource(javax.faces.context.FacesContext context, String name, String library, String target)
-
addComponentResource
public static void addComponentResource(javax.faces.context.FacesContext context, String name, String library)
-
addComponentResource
public static void addComponentResource(javax.faces.context.FacesContext context, String name)
-
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
public static boolean isInline(ResourceUtils.ResourceInfo resourceInfo)
-
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)
-
-