java.lang.Object
jakarta.faces.application.ViewResource
jakarta.faces.application.Resource
org.omnifaces.resourcehandler.DynamicResource
org.omnifaces.resourcehandler.GraphicResource
This Resource implementation is used by the GraphicImage component.
- Since:
- 2.0
- Author:
- Bauke Scholtz
-
Field Summary
Fields inherited from class jakarta.faces.application.Resource
COMPONENT_RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionGraphicResource(Object content, String contentType) Construct a new graphic resource which uses the given content as data URI.GraphicResource(String name, String[] params, Object lastModified) Construct a new graphic resource based on the given name, EL method parameters converted as string, and the "last modified" representation. -
Method Summary
Modifier and TypeMethodDescriptionstatic GraphicResourcecreate(FacesContext context, ValueExpression value, String type, Object lastModified) Create a new graphic resource based on the given value expression.An override which either returns the data URI or appends the converted method parameters to the query string.static voidRegister graphic image scoped beans discovered so far.Methods inherited from class org.omnifaces.resourcehandler.DynamicResource
getLastModified, getResponseHeaders, getURL, setLastModified, userAgentNeedsUpdateMethods inherited from class jakarta.faces.application.Resource
getContentType, getLibraryName, getResourceName, setContentType, setLibraryName, setResourceName, toString
-
Constructor Details
-
GraphicResource
Construct a new graphic resource which uses the given content as data URI. This constructor is called during render time of<o:graphicImage ... dataURI="true">.- Parameters:
content- The graphic resource content, to be represented as data URI.contentType- The graphic resource content type. If this isnull, then it will be guessed based on the content type signature in the content header. So far, WEBP, JPEG, PNG, GIF, ICO, SVG, BMP and TIFF are recognized. Else if this represents the file extension, then it will be resolved based on mime mappings.
-
GraphicResource
Construct a new graphic resource based on the given name, EL method parameters converted as string, and the "last modified" representation. This constructor is called during render time of<o:graphicImage value="..." dataURI="false">and during handling the resource request byGraphicResourceHandler.- Parameters:
name- The graphic resource name, usually representing the base and method of EL method expression.params- The graphic resource method parameters.lastModified- The "last modified" representation of the graphic resource, can beLongorDate, or otherwise an attempt will be made to parse it asLong.- Throws:
IllegalArgumentException- If "last modified" can not be parsed to a timestamp.
-
-
Method Details
-
create
public static GraphicResource create(FacesContext context, ValueExpression value, String type, Object lastModified) Create a new graphic resource based on the given value expression.- Parameters:
context- The involved faces context.value- The value expression representing content to create a new graphic resource for.type- The image type, represented as file extension. E.g. "webp", "jpg", "png", "gif", "ico", "svg", "bmp", "tiff", etc.lastModified- The "last modified" representation of the graphic resource, can beLongorDate, or otherwise an attempt will be made to parse it asLong.- Returns:
- The new graphic resource.
- Throws:
IllegalArgumentException- When the "value" attribute of the given component is absent or does not represent a method expression referring an existing method taking at least one argument. Or, when the "type" attribute does not represent a valid file extension (you can add unrecognized ones as<mime-mapping>inweb.xml).
-
getRequestPath
An override which either returns the data URI or appends the converted method parameters to the query string.- Overrides:
getRequestPathin classDynamicResource
-
getInputStream
- Specified by:
getInputStreamin classResource- Throws:
IOException
-
registerGraphicImageBeans
public static void registerGraphicImageBeans()Register graphic image scoped beans discovered so far.- Throws:
IllegalArgumentException- When bean method is missing.
-