public class GraphicResource extends DynamicResource
This Resource
implementation is used by the GraphicImage
component.
COMPONENT_RESOURCE_KEY
Constructor and Description |
---|
GraphicResource(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.
|
Modifier and Type | Method and Description |
---|---|
static GraphicResource |
create(FacesContext context,
ValueExpression value,
String type,
Object lastModified)
Create a new graphic resource based on the given value expression.
|
InputStream |
getInputStream() |
String |
getRequestPath()
An override which either returns the data URI or appends the converted method parameters to the query string.
|
static void |
registerGraphicImageBeans()
Register graphic image scoped beans discovered so far.
|
getLastModified, getResponseHeaders, getURL, setLastModified, userAgentNeedsUpdate
getContentType, getLibraryName, getResourceName, setContentType, setLibraryName, setResourceName, toString
public GraphicResource(Object content, String contentType)
<o:graphicImage ... dataURI="true">
.content
- The graphic resource content, to be represented as data URI.contentType
- The graphic resource content type. If this is null
, then it will be guessed
based on the content type signature in the content header. So far, 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.public GraphicResource(String name, String[] params, Object lastModified)
<o:graphicImage value="..." dataURI="false">
and during handling the resource request by GraphicResourceHandler
.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 be Long
or
Date
, or otherwise an attempt will be made to parse it as Long
.IllegalArgumentException
- If "last modified" can not be parsed to a timestamp.public static GraphicResource create(FacesContext context, ValueExpression value, String type, Object lastModified)
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. "jpg", "png", "gif", "ico", "svg", "bmp",
"tiff", etc.lastModified
- The "last modified" representation of the graphic resource, can be Long
or
Date
, or otherwise an attempt will be made to parse it as Long
.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>
in web.xml
).public String getRequestPath()
getRequestPath
in class DynamicResource
public InputStream getInputStream() throws IOException
getInputStream
in class Resource
IOException
public static void registerGraphicImageBeans()
IllegalArgumentException
- When bean method is missing.Copyright © 2012–2018 OmniFaces. All rights reserved.