public class XhtmlHelper extends Object
Helper bean for rendering links to download resources commonly used in HTML and XHTML pages. The specified resource identifier is automatically mapped based upon the Shale Remoting configuration that this application is using, as well as adapting to the servlet mapping for the JavaServer Faces controller servlet. A given resource identifier will only be linked once for a given request.
Instances of this class are stateless and have no side effects.
Modifier and Type | Field and Description |
---|---|
protected static String |
PREFIX
The prefix to the request attributes that we will use to keep track
of whether a particular resource has been linked already.
|
Constructor and Description |
---|
XhtmlHelper() |
Modifier and Type | Method and Description |
---|---|
protected void |
link(javax.faces.context.FacesContext context,
String resourceId)
Mark the specified resource identifier as having already been
linked in the current request.
|
protected boolean |
linked(javax.faces.context.FacesContext context,
String resourceId)
Return
true if the specified resource identifier has
already been linked in the current request, and should therefore not
be linked again. |
void |
linkJavascript(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
javax.faces.context.ResponseWriter writer,
Mechanism mechanism,
String resourceId)
Render a link to a JavaScript resource at the specified resource
identifier.
|
void |
linkJavascript(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
javax.faces.context.ResponseWriter writer,
Mechanism mechanism,
String resourceId,
String contentType)
Render a link to a JavaScript resource at the specified resource
identifier.
|
void |
linkStylesheet(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
javax.faces.context.ResponseWriter writer,
Mechanism mechanism,
String resourceId)
Render a link to a CSS stylesheet at the specified resource
identifier.
|
String |
mapResourceId(javax.faces.context.FacesContext context,
Mechanism mechanism,
String resourceId)
Map the specified resource identifier to a request URL, taking into
account the mappings for the specified mechanism and the servlet mapping
for the JavaServer Faces controller servlet.
|
protected ResourceBundle |
resourceBundle(javax.faces.context.FacesContext context)
Return the localized resource bundle we should use to generate
exception or log messages for this request.
|
protected static final String PREFIX
The prefix to the request attributes that we will use to keep track of whether a particular resource has been linked already.
public void linkJavascript(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, Mechanism mechanism, String resourceId) throws IOException
Render a link to a JavaScript resource at the specified resource identifier.
context
- FacesContext
for the current requestcomponent
- UIComponent
being renderedwriter
- ResponseWriter
to render output tomechanism
- Mechanism used to retrieve the specified resource
(used to select the appropriate Processor
resourceId
- Resource identifier used to retrieve the requested
JavaScript resourceIllegalArgumentException
- if mechanism
or
resourceId
is null
IllegalStateException
- if a configuration error prevents
the mapping of this resource identifier to a corresponding URIIOException
- if an input/output error occurspublic void linkJavascript(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, Mechanism mechanism, String resourceId, String contentType) throws IOException
Render a link to a JavaScript resource at the specified resource identifier.
context
- FacesContext
for the current requestcomponent
- UIComponent
being renderedwriter
- ResponseWriter
to render output tomechanism
- Mechanism used to retrieve the specified resource
(used to select the appropriate Processor
resourceId
- Resource identifier used to retrieve the requested
JavaScript resourcecontentType
- Content type to specify (for pulling specific
versions of JavaScript resources)IllegalArgumentException
- if mechanism
or
resourceId
is null
IllegalStateException
- if a configuration error prevents
the mapping of this resource identifier to a corresponding URIIOException
- if an input/output error occurspublic void linkStylesheet(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, Mechanism mechanism, String resourceId) throws IOException
Render a link to a CSS stylesheet at the specified resource identifier.
context
- FacesContext
for the current requestcomponent
- UIComponent
being renderedwriter
- ResponseWriter
to render output tomechanism
- Mechanism used to retrieve the specified resource
(used to select the appropriate Processor
resourceId
- Resource identifier used to retrieve the requested
stylesheet resourceIllegalArgumentException
- if mechanism
or
resourceId
is null
IllegalStateException
- if a configuration error prevents
the mapping of this resource identifier to a corresponding URIIOException
- if an input/output error occurspublic String mapResourceId(javax.faces.context.FacesContext context, Mechanism mechanism, String resourceId)
Map the specified resource identifier to a request URL, taking into account the mappings for the specified mechanism and the servlet mapping for the JavaServer Faces controller servlet.
context
- FacesContext
for the current requestmechanism
- Requested mechanismresourceId
- Resource identifier to be mappedIllegalArgumentException
- if mechanism
or
resourceId
is null
IllegalStateException
- if a configuration error prevents
the mapping of this resource identifier to a corresponding URIprotected void link(javax.faces.context.FacesContext context, String resourceId)
Mark the specified resource identifier as having already been linked in the current request.
context
- FacesContext
for the current requestresourceId
- Resource identifier to mark as having been linkedprotected boolean linked(javax.faces.context.FacesContext context, String resourceId)
Return true
if the specified resource identifier has
already been linked in the current request, and should therefore not
be linked again.
context
- FacesContext
for the current requestresourceId
- Resource identifier to check for prior linkingprotected ResourceBundle resourceBundle(javax.faces.context.FacesContext context)
Return the localized resource bundle we should use to generate exception or log messages for this request.
context
- FacesContext
for this requestCopyright © 2004-2013 Apache Software Foundation. All Rights Reserved.