| java.lang.Object de.danet.an.util.jsf.PortletAppAddResource
PortletAppAddResource | public class PortletAppAddResource implements AddResource(Code) | | This class provides an adapted AddResource implementation.
author: Michael Lipp |
Method Summary | |
public void | addInlineScriptAtPosition(FacesContext context, ResourcePosition position, String inlineScript) Adds the given Inline Script at the specified document position. | public void | addInlineStyleAtPosition(FacesContext context, ResourcePosition position, String inlineStyle) Adds the given Inline Style at the specified document position. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler) Adds the given Javascript resource to the document header at the
specified document positioy by supplying a resourcehandler instance. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName) Insert a [script src="url"] entry into the document header at the
specified document position. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName, boolean defer) Insert a [script src="url"] entry into the document header at the
specified document position. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, String uri) Insert a [script src="url"] entry into the document header at the
specified document position. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, String uri, boolean defer) Adds the given Javascript resource at the specified document position. | public void | addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler, boolean defer) Adds the given Javascript resource at the specified document position. | public void | addJavaScriptAtPositionPlain(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName) | public void | addJavaScriptHere(FacesContext context, Class myfacesCustomComponent, String resourceName) Insert a [script src="url"] entry at the current location in the
response. | public void | addJavaScriptHere(FacesContext context, String uri) Insert a [script src="url"] entry at the current location in the
response. | public void | addJavaScriptHere(FacesContext context, ResourceHandler resourceHandler) Insert a [script src="url"] entry at the current location in the
response.
Parameters: context - Parameters: resourceHandler - is an object which specifies exactly how to build the url thatis emitted into the script tag. | public void | addJavaScriptHerePlain(FacesContext context, String uri) | public void | addJavaScriptToBodyTag(FacesContext context, String javascriptEventName, String addedJavaScript) | public void | addResourceHere(FacesContext context, ResourceHandler resourceHandler) | public void | addStyleSheet(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName) Adds the given Style Sheet at the specified document position. | public void | addStyleSheet(FacesContext context, ResourcePosition position, String uri) Adds the given Style Sheet at the specified document position. | public void | addStyleSheet(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler) Adds the given Style Sheet at the specified document position. | protected long | getCacheKey(FacesContext context) Return a value used in the {cacheKey} part of a generated URL for a
resource reference.
Caching in browsers normally works by having files served to them
include last-modified and expiry-time http headers. | public String | getResourceUri(FacesContext context, Class myfacesCustomComponent, String resource, boolean withContextPath) | public String | getResourceUri(FacesContext context, Class myfacesCustomComponent, String resource) | public String | getResourceUri(FacesContext context, ResourceHandler resourceHandler) Get the Path used to retrieve an resource. | public String | getResourceUri(FacesContext context, ResourceHandler resourceHandler, boolean withContextPath) Get the Path used to retrieve an resource. | public String | getResourceUri(FacesContext context, String uri) Get the Path used to retrieve an resource. | public String | getResourceUri(FacesContext context, String uri, boolean withContextPath) Get the Path used to retrieve an resource. | protected String | getResourceUri(FacesContext context, Class resourceLoader, boolean withContextPath) Get the Path used to retrieve an resource. | public boolean | hasHeaderBeginInfos() | public boolean | isResourceUri(HttpServletRequest request) | public void | parseResponse(HttpServletRequest request, String bufferedResponse, HttpServletResponse response) | public void | processAppendices(RenderRequest request, RenderResponse response, FacesContext facesContext) | public boolean | requiresBuffer() | public void | responseFinished() | public void | responseStarted() | public void | serveResource(ServletContext context, HttpServletRequest request, HttpServletResponse response) | public void | setContextPath(String contextPath) | protected void | validateResourceHandler(ResourceHandler resourceHandler) Verify that the resource handler is acceptable. | protected void | validateResourceLoader(Class resourceloader) Given a Class object, verify that the instances of that class implement
the ResourceLoader interface. | public void | writeMyFacesJavascriptBeforeBodyEnd(HttpServletRequest request, HttpServletResponse response) | public void | writeResponse(HttpServletRequest request, HttpServletResponse response) | public void | writeWithFullHeader(HttpServletRequest request, HttpServletResponse response) |
addInlineScriptAtPosition | public void addInlineScriptAtPosition(FacesContext context, ResourcePosition position, String inlineScript)(Code) | | Adds the given Inline Script at the specified document position.
|
addInlineStyleAtPosition | public void addInlineStyleAtPosition(FacesContext context, ResourcePosition position, String inlineStyle)(Code) | | Adds the given Inline Style at the specified document position.
|
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler)(Code) | | Adds the given Javascript resource to the document header at the
specified document positioy by supplying a resourcehandler instance.
Use this method to have full control about building the reference url to
identify the resource and to customize how the resource is written to the
response. In most cases, however, one of the convenience methods on this
class can be used without requiring a custom ResourceHandler to be
provided.
If the script has already been referenced, it's added only
once.
Note that this method queues the javascript for
insertion, and that the script is inserted into the buffered response by
the ExtensionsFilter after the page is complete.
|
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName)(Code) | | Insert a [script src="url"] entry into the document header at the
specified document position. If the script has already been referenced,
it's added only once.
The resource is expected to be in the
classpath, at the same location as the specified component + "/resource".
Example: when customComponent is class example.Widget, and
resourceName is script.js, the resource will be retrieved from
"example/Widget/resource/script.js" in the classpath.
|
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName, boolean defer)(Code) | | Insert a [script src="url"] entry into the document header at the
specified document position. If the script has already been referenced,
it's added only once.
Parameters: defer - specifies whether the html attribute "defer" is set on thegenerated script tag. If this is true then the browser willcontinue processing the html page without waiting for thespecified script to load and be run. |
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, String uri)(Code) | | Insert a [script src="url"] entry into the document header at the
specified document position. If the script has already been referenced,
it's added only once.
Parameters: uri - is the location of the desired resource, relative to the basedirectory of the webapp (ie its contextPath). |
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, String uri, boolean defer)(Code) | | Adds the given Javascript resource at the specified document position. If
the script has already been referenced, it's added only once.
|
addJavaScriptAtPosition | public void addJavaScriptAtPosition(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler, boolean defer)(Code) | | Adds the given Javascript resource at the specified document position. If
the script has already been referenced, it's added only once.
|
addJavaScriptAtPositionPlain | public void addJavaScriptAtPositionPlain(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName)(Code) | | |
addJavaScriptHere | public void addJavaScriptHere(FacesContext context, Class myfacesCustomComponent, String resourceName) throws IOException(Code) | | Insert a [script src="url"] entry at the current location in the
response. The resource is expected to be in the classpath, at the same
location as the specified component + "/resource". Example: when
customComponent is class example.Widget, and resourceName is script.js,
the resource will be retrieved from "example/Widget/resource/script.js"
in the classpath.
|
addJavaScriptHere | public void addJavaScriptHere(FacesContext context, String uri) throws IOException(Code) | | Insert a [script src="url"] entry at the current location in the
response.
Parameters: uri - is the location of the desired resource, relative to the basedirectory of the webapp (ie its contextPath). |
addJavaScriptHere | public void addJavaScriptHere(FacesContext context, ResourceHandler resourceHandler) throws IOException(Code) | | Insert a [script src="url"] entry at the current location in the
response.
Parameters: context - Parameters: resourceHandler - is an object which specifies exactly how to build the url thatis emitted into the script tag. Code which needs to generateURLs in ways that this class does not support by default canimplement a custom ResourceHandler. throws: IOException - |
addJavaScriptHerePlain | public void addJavaScriptHerePlain(FacesContext context, String uri) throws IOException(Code) | | |
addJavaScriptToBodyTag | public void addJavaScriptToBodyTag(FacesContext context, String javascriptEventName, String addedJavaScript)(Code) | | |
addResourceHere | public void addResourceHere(FacesContext context, ResourceHandler resourceHandler) throws IOException(Code) | | |
addStyleSheet | public void addStyleSheet(FacesContext context, ResourcePosition position, Class myfacesCustomComponent, String resourceName)(Code) | | Adds the given Style Sheet at the specified document position. If the
style sheet has already been referenced, it's added only once.
|
addStyleSheet | public void addStyleSheet(FacesContext context, ResourcePosition position, String uri)(Code) | | Adds the given Style Sheet at the specified document position. If the
style sheet has already been referenced, it's added only once.
|
addStyleSheet | public void addStyleSheet(FacesContext context, ResourcePosition position, ResourceHandler resourceHandler)(Code) | | Adds the given Style Sheet at the specified document position. If the
style sheet has already been referenced, it's added only once.
|
getCacheKey | protected long getCacheKey(FacesContext context)(Code) | | Return a value used in the {cacheKey} part of a generated URL for a
resource reference.
Caching in browsers normally works by having files served to them
include last-modified and expiry-time http headers. Until the expiry
time is reached, a browser will silently use its cached version. After
the expiry time, it will send a "get if modified since {time}" message,
where {time} is the last-modified header from the version it has cached.
Unfortunately this scheme only works well for resources represented as
plain files on disk, where the webserver can easily and efficiently see
the last-modified time of the resource file. When that query has to be
processed by a servlet that doesn't scale well, even when it is possible
to determine the resource's last-modified date from servlet code.
Fortunately, for the AddResource class a static resource is only ever
accessed because a URL was embedded by this class in a dynamic page.
This makes it possible to implement caching by instead marking every
resource served with a very long expiry time, but forcing the URL that
points to the resource to change whenever the old cached version becomes
invalid; the browser effectively thinks it is fetching a different
resource that it hasn't seen before. This is implemented by embedding
a "cache key" in the generated URL.
Rather than using the actual modification date of a resource as the
cache key, we simply use the webapp deployment time. This means that all
data cached by browsers will become invalid after a webapp deploy (all
the urls to the resources change). It also means that changes that occur
to a resource without a webapp redeploy will not be seen by browsers.
|
getResourceUri | public String getResourceUri(FacesContext context, Class myfacesCustomComponent, String resource, boolean withContextPath)(Code) | | |
getResourceUri | public String getResourceUri(FacesContext context, Class myfacesCustomComponent, String resource)(Code) | | |
getResourceUri | public String getResourceUri(FacesContext context, ResourceHandler resourceHandler)(Code) | | Get the Path used to retrieve an resource.
|
getResourceUri | public String getResourceUri(FacesContext context, ResourceHandler resourceHandler, boolean withContextPath)(Code) | | Get the Path used to retrieve an resource.
|
getResourceUri | public String getResourceUri(FacesContext context, String uri)(Code) | | Get the Path used to retrieve an resource.
|
getResourceUri | public String getResourceUri(FacesContext context, String uri, boolean withContextPath)(Code) | | Get the Path used to retrieve an resource.
|
getResourceUri | protected String getResourceUri(FacesContext context, Class resourceLoader, boolean withContextPath)(Code) | | Get the Path used to retrieve an resource.
|
hasHeaderBeginInfos | public boolean hasHeaderBeginInfos()(Code) | | |
processAppendices | public void processAppendices(RenderRequest request, RenderResponse response, FacesContext facesContext) throws IOException(Code) | | |
requiresBuffer | public boolean requiresBuffer()(Code) | | |
responseFinished | public void responseFinished()(Code) | | |
responseStarted | public void responseStarted()(Code) | | |
setContextPath | public void setContextPath(String contextPath)(Code) | | |
validateResourceHandler | protected void validateResourceHandler(ResourceHandler resourceHandler)(Code) | | Verify that the resource handler is acceptable. Null is not valid, and
the getResourceLoaderClass method must return a Class object whose
instances implements the ResourceLoader interface.
Parameters: resourceHandler - |
validateResourceLoader | protected void validateResourceLoader(Class resourceloader)(Code) | | Given a Class object, verify that the instances of that class implement
the ResourceLoader interface.
Parameters: resourceloader - |
|
|