|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.application.Resource
public abstract class Resource
An instance of
Resource
is a Java object representation of the artifact
that is served up in response to a resource request from the
client. Instances of Resource
are normally created and
initialized via calls to ResourceHandler#createResource
. See
the documentation for ResourceHandler
for more
information.
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_RESOURCE_KEY
This constant is used as the key in the
component attribute map of a composite component to associate
the component with its |
Constructor Summary | |
---|---|
Resource()
|
Method Summary | |
---|---|
java.lang.String |
getContentType()
Return the MIME content-type for this resource. |
abstract java.io.InputStream |
getInputStream()
If the current request is a resource
request, (that is, |
java.lang.String |
getLibraryName()
Return the libraryName for this resource. |
abstract java.lang.String |
getRequestPath()
Return a path to this resource such that, when the browser resolves it against the base URI for the view that includes the resource, and issues a GET request to the resultant fully qualified URL, the bytes of the resource are returned in response. |
java.lang.String |
getResourceName()
Return the resourceName for this resource. |
abstract java.util.Map<java.lang.String,java.lang.String> |
getResponseHeaders()
Returns a mutable
|
abstract java.net.URL |
getURL()
Return an actual |
void |
setContentType(java.lang.String contentType)
Set the MIME content-type for this resource. |
void |
setLibraryName(java.lang.String libraryName)
Set the libraryName for this resource. |
void |
setResourceName(java.lang.String resourceName)
Set the resourceName for this resource. |
java.lang.String |
toString()
Call through to |
abstract boolean |
userAgentNeedsUpdate(FacesContext context)
Return |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_RESOURCE_KEY
This constant is used as the key in the
component attribute map of a composite component to associate
the component with its Resource
instance. The
value for this key is the actual Resource
instance.
Constructor Detail |
---|
public Resource()
Method Detail |
---|
public java.lang.String getContentType()
Return the MIME content-type for this resource.
public void setContentType(java.lang.String contentType)
Set the MIME content-type for this resource. The default implementation performs no validation on the argument.
contentType
- the MIME content-type for this resource. The
default implementation must accept null
as a
parameter.public java.lang.String getLibraryName()
Return the libraryName for this
resource. May be null
. The libraryName for a
resource is an optional String that indicates membership in a
"resource library". All resources with the same libraryName
belong to the same "resource library". The "resource library"
concept allows disambiguating resources that have the same
resourceName. See ResourceHandler
for more
information.
null
.public void setLibraryName(java.lang.String libraryName)
Set the libraryName for this resource.
libraryName
- the libraryName for this resource. The
default implementation must accept null
for the
libraryName.public java.lang.String getResourceName()
Return the resourceName for this resource.
Will never be null. All Resource
instances must
have a resourceName.
public void setResourceName(java.lang.String resourceName)
Set the resourceName for this resource.
resourceName
- a non-null String.
java.lang.NullPointerException
- if argument
resourceName
is null.public abstract java.io.InputStream getInputStream() throws java.io.IOException
If the current request is a resource
request, (that is, ResourceHandler#isResourceRequest
returns true
), return an InputStream
containing the bytes of the resource. Otherwise, throw an
IOException
.
InputStream
containing the bytes of the
resource.
Any EL expressions present in the resource must be evaluated before serving the bytes of the resource. Note that due to browser and server caching, EL expressions in a resource file will generally only be evaluated once, when the resource is first served up. Therefore, using EL expressions that refer to per-request data is not advisable since this data can become stale.
java.io.IOException
- if the current request is not a resource request.public abstract java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()
Returns a mutable
Map<String, String>
whose entries will be sent
as response headers during ResourceHandler#handleResourceRequest
. The entries in this map
must not persist beyond the scope of a single request. Any
modifications made to the map after the resource has been served
will be ignored by the run-time.
Map<String, String>
of
headers that will be included with the response.public abstract java.lang.String getRequestPath()
Return a path to this resource such that, when the browser resolves it against the base URI for the view that includes the resource, and issues a GET request to the resultant fully qualified URL, the bytes of the resource are returned in response.
The default implementation must implement the following algorithm. For discussion, the return result from this method will be called result.
Get the context-root for this web application, not ending in slash. For discussion this will be caled contextRoot.
Discover if the FacesServlet
is prefix or
extension mapped, and the value of the mapping (including the
leading '.' in the case of extension mapping). For discussion,
this will be facesServletMapping.
If prefix mapped, result must be
result = contextRoot + '/' +
facesServletMapping +
ResourceHandler#RESOURCE_IDENTIFIER
+ '/' + getResourceName()
If extension mapped, result must be
result = contextRoot +
ResourceHandler#RESOURCE_IDENTIFIER
+ getResourceName()
+
facesServletMapping
If getLibraryName()
returns non-null
,
build up a string, called resourceMetaData for
discussion, as follows:
resourceMetaData = "?ln=" +
getLibraryName()
Append resourceMetaData to result.
Make it portlet safe by passing the result through ViewHandler#getResourceURL
.
public abstract java.net.URL getURL()
Return an actual URL
instance that refers to this resource instance.
URL
instance that refers to
this resource instance.public java.lang.String toString()
Call through to getRequestPath()
and return the result.
toString
in class java.lang.Object
getRequestPath()
and return the
result.public abstract boolean userAgentNeedsUpdate(FacesContext context)
Return true
if the
user-agent requesting this resource needs an update. Returns
false
otherwise.
true
or false
depending on
whether or not the user-agent needs an update of this resource.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.
Generated on 10-February-2011 12:41