Class GraphicResource

    • Constructor Detail

      • GraphicResource

        public GraphicResource​(Object content,
                               String contentType)
        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 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.
      • GraphicResource

        public 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. This constructor is called during render time of <o:graphicImage value="..." dataURI="false"> and during handling the resource request by GraphicResourceHandler.
        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 be Long or Date, or otherwise an attempt will be made to parse it as Long.
        Throws:
        IllegalArgumentException - If "last modified" can not be parsed to a timestamp.
    • Method Detail

      • 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. "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.
        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> in web.xml).
      • getRequestPath

        public String getRequestPath()
        An override which either returns the data URI or appends the converted method parameters to the query string.
        Overrides:
        getRequestPath in class DynamicResource
      • registerGraphicImageBeans

        public static void registerGraphicImageBeans()
        Register graphic image scoped beans discovered so far.
        Throws:
        IllegalArgumentException - When bean method is missing.