Class ResourceHandler

java.lang.Object
jakarta.faces.application.ResourceHandler
Direct Known Subclasses:
ResourceHandlerImpl, ResourceHandlerWrapper

public abstract class ResourceHandler extends Object

ResourceHandler is the run-time API by which UIComponent and Renderer instances, and the ViewDeclarationLanguage can reference Resource instances. An implementation of this class must be thread-safe.

Packaging Resources

ResourceHandler defines a path based packaging convention for resources. The default implementation of ResourceHandler must support packaging resources in the classpath or in the web application root. See section 2.6.1 "Packaging Resources" of the Jakarta Faces Specification Document for the normative specification of packaging resources.

Briefly, The default implementation must support packaging resources in the web application root under the path

resources/<resourceIdentifier>

relative to the web app root. "resources" is the default location, but this location can be changed by the value of the WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME <context-param>.

For the default implementation, resources packaged in the classpath must reside under the JAR entry name

META-INF/resources/<resourceIdentifier>

In the case of Faces Flows packaged within jar files, resources packaged in the classpath must reside under the jar entry name

META-INF/flows/<resourceIdentifier>

<resourceIdentifier> consists of several segments, specified as follows.

[localePrefix/][libraryName/][libraryVersion/]resourceName[/resourceVersion]

None of the segments in the resourceIdentifier may be relative paths, such as ‘../otherLibraryName’. The implementation is not required to support the libraryVersion and resourceVersion segments for the JAR packaging case.

Note that resourceName is the only required segment.

Encoding Resources

During the handling of view requests, the Jakarta Server Face run-time may be called upon to encode a resource in such a way as to instruct the user-agent to make a subsequent resource request. This behavior is orchestrated by one of the resource renderers (ScriptRenderer, StylesheetRenderer, ImageRenderer), which all call Resource.getRequestPath() to obtain the encoded URI for the resource. See Resource.getRequestPath() and the Standard HTML RenderKit specification for the complete specification.

This usage of resources does not apply for resources that correspond to VDL resources.

Decoding Resources

During the handling of resource requests, the Jakarta Faces run-time will be called upon to decode a resource in such a way as to serve up the bytes of the resource to the user-agent. This behavior is orchestrated by handleResourceRequest(jakarta.faces.context.FacesContext), which calls Resource.getInputStream() to obtain bytes of the resource. See handleResourceRequest(jakarta.faces.context.FacesContext) for the complete specification.

This usage of resources does not apply for resources that correspond to VDL resources.

Since:
2.0