org.apache.shale.remoting
Class XhtmlHelper

java.lang.Object
  extended by org.apache.shale.remoting.XhtmlHelper

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.


Field Summary
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 Summary
XhtmlHelper()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

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.

See Also:
Constant Field Values
Constructor Detail

XhtmlHelper

public XhtmlHelper()
Method Detail

linkJavascript

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.

Parameters:
context - FacesContext for the current request
component - UIComponent being rendered
writer - ResponseWriter to render output to
mechanism - Mechanism used to retrieve the specified resource (used to select the appropriate Processor
resourceId - Resource identifier used to retrieve the requested JavaScript resource
Throws:
IllegalArgumentException - if mechanism or resourceId is null
IllegalStateException - if a configuration error prevents the mapping of this resource identifier to a corresponding URI
IOException - if an input/output error occurs

linkJavascript

public 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.

Parameters:
context - FacesContext for the current request
component - UIComponent being rendered
writer - ResponseWriter to render output to
mechanism - Mechanism used to retrieve the specified resource (used to select the appropriate Processor
resourceId - Resource identifier used to retrieve the requested JavaScript resource
contentType - Content type to specify (for pulling specific versions of JavaScript resources)
Throws:
IllegalArgumentException - if mechanism or resourceId is null
IllegalStateException - if a configuration error prevents the mapping of this resource identifier to a corresponding URI
IOException - if an input/output error occurs

linkStylesheet

public 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.

Parameters:
context - FacesContext for the current request
component - UIComponent being rendered
writer - ResponseWriter to render output to
mechanism - Mechanism used to retrieve the specified resource (used to select the appropriate Processor
resourceId - Resource identifier used to retrieve the requested stylesheet resource
Throws:
IllegalArgumentException - if mechanism or resourceId is null
IllegalStateException - if a configuration error prevents the mapping of this resource identifier to a corresponding URI
IOException - if an input/output error occurs

mapResourceId

public 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.

Parameters:
context - FacesContext for the current request
mechanism - Requested mechanism
resourceId - Resource identifier to be mapped
Throws:
IllegalArgumentException - if mechanism or resourceId is null
IllegalStateException - if a configuration error prevents the mapping of this resource identifier to a corresponding URI

link

protected void link(javax.faces.context.FacesContext context,
                    String resourceId)

Mark the specified resource identifier as having already been linked in the current request.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier to mark as having been linked

linked

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.

Parameters:
context - FacesContext for the current request
resourceId - Resource identifier to check for prior linking

resourceBundle

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.

Parameters:
context - FacesContext for this request


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.