com.sun.rave.web.ui.util
Class RenderingUtilities

java.lang.Object
  extended by com.sun.rave.web.ui.util.RenderingUtilities

public class RenderingUtilities
extends java.lang.Object


Nested Class Summary
protected static class RenderingUtilities.Param
           
 
Field Summary
static java.lang.String COLON
           
static char COLON_CHAR
           
static java.lang.String MEDIA
           
static java.lang.String NL
           
static java.lang.String SCRIPT
           
static java.lang.String SJWUIC_JSFILE
           
static java.lang.String SRC
           
static java.lang.String TYPE
           
static java.lang.String USCORE
           
static char USCORE_CHAR
           
 
Constructor Summary
RenderingUtilities()
          Creates a new instance of RenderingUtilities.
 
Method Summary
static java.lang.String getJavascriptId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
static java.lang.String getJsObjectName(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String objectPrefix)
           
static java.lang.String getJsObjectName(java.lang.String clientId, java.lang.String objectPrefix)
           
static java.lang.String getLastClientID(javax.faces.context.FacesContext context)
          Get the client ID of the last component to have focus.
protected static RenderingUtilities.Param[] getParamList(javax.faces.context.FacesContext context, javax.faces.component.UIComponent command)
           
static java.lang.String getStyleClasses(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String styles)
          Return a space-separated list of CSS style classes to render for this component, or null for none.
static void includeJsp(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, java.lang.String jspURI)
          Perform a RequestDispatcher.include of the specified URI jspURI.
static boolean isPortlet(javax.faces.context.FacesContext context)
           
static boolean isVisible(javax.faces.component.UIComponent component)
           Return whether the given UIComponent is "visible".
static void renderAnchor(java.lang.String anchorName, javax.faces.component.UIComponent component, javax.faces.context.FacesContext context)
           
static void renderComponent(javax.faces.component.UIComponent component, javax.faces.context.FacesContext context)
          Render a component.
static void renderExtraHtmlAttributes(javax.faces.context.ResponseWriter writer, java.lang.String extraHtml)
          Helper method to render extra attributes.
static void renderHiddenField(javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, java.lang.String id, java.lang.String value)
          This method will output a hidden field for use with Params and components that need to submit a value through a hidden field.
static void renderJavaScript(javax.faces.component.UIComponent component, Theme theme, javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer)
          Helper function to render theme scripts
static boolean renderJsInclude(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Theme theme, javax.faces.context.ResponseWriter writer, java.lang.String includeFile)
          Return true if the javascript file identified by includeFile is included.
static boolean renderJsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, java.lang.String objectName, java.lang.String jsObjectClass, java.lang.String arguments)
           
static void renderSkipLink(java.lang.String anchorName, java.lang.String styleClass, java.lang.String style, java.lang.String toolTip, java.lang.Integer tabIndex, javax.faces.component.UIComponent component, javax.faces.context.FacesContext context)
           
static void renderSpacer(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, int height, int width)
          Helper function to render a transparent spacer image.
static void renderSpacer(javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, java.lang.String dotSrc, int height, int width)
          Helper function to render a transparent spacer image.
static void renderStyleClass(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, java.lang.String extraStyles)
           
static java.lang.String renderStyleClass(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, java.lang.String styleClass, java.lang.String extraHtml)
          Helper method to render style classes when name/value pairs are given via an extraHtml String.
static void renderStyleSheetInline(javax.faces.component.UIComponent component, Theme theme, javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer)
          Helper function to render theme stylesheet definitions inline
static void renderStyleSheetLink(javax.faces.component.UIComponent component, Theme theme, javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer)
          Helper function to render theme stylesheet link(s)
static void renderURLAttribute(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component, java.lang.String name, java.lang.String url, java.lang.String compPropName)
          Helper function to render a typical URL
static void setLastClientID(javax.faces.context.FacesContext context, java.lang.String clientId)
          Set the client ID of the last component to have focus.
static void writeStringAttributes(javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, java.lang.String[] possibleAttributes)
          This method goes through an array of possible attribute names, evaluates if they have been set on the component, and writes them out using the specified writer.
static void writeStringAttributes(javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, java.lang.String[] names, java.lang.String extraHtml)
          Add any attributes on the specified list directly to the specified ResponseWriter for which the specified UIComponent has a non-null String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NL

public static final java.lang.String NL
See Also:
Constant Field Values

SCRIPT

public static final java.lang.String SCRIPT
See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

SRC

public static final java.lang.String SRC
See Also:
Constant Field Values

MEDIA

public static final java.lang.String MEDIA
See Also:
Constant Field Values

SJWUIC_JSFILE

public static final java.lang.String SJWUIC_JSFILE
See Also:
Constant Field Values

USCORE

public static final java.lang.String USCORE
See Also:
Constant Field Values

COLON

public static final java.lang.String COLON
See Also:
Constant Field Values

USCORE_CHAR

public static final char USCORE_CHAR
See Also:
Constant Field Values

COLON_CHAR

public static final char COLON_CHAR
See Also:
Constant Field Values
Constructor Detail

RenderingUtilities

public RenderingUtilities()
Creates a new instance of RenderingUtilities.

Method Detail

renderComponent

public static void renderComponent(javax.faces.component.UIComponent component,
                                   javax.faces.context.FacesContext context)
                            throws java.io.IOException
Render a component.

Parameters:
component - The component to render
context - The FacesContext of the request
Throws:
java.io.IOException

writeStringAttributes

public static void writeStringAttributes(javax.faces.component.UIComponent component,
                                         javax.faces.context.ResponseWriter writer,
                                         java.lang.String[] possibleAttributes)
                                  throws java.io.IOException
This method goes through an array of possible attribute names, evaluates if they have been set on the component, and writes them out using the specified writer.

Parameters:
component - The component being rendered
writer - The writer to use to write the attributes
possibleAttributes - String attributes that are treated as passthrough for this component
Throws:
java.io.IOException

writeStringAttributes

public static void writeStringAttributes(javax.faces.component.UIComponent component,
                                         javax.faces.context.ResponseWriter writer,
                                         java.lang.String[] names,
                                         java.lang.String extraHtml)
                                  throws java.io.IOException
Add any attributes on the specified list directly to the specified ResponseWriter for which the specified UIComponent has a non-null String value. This method may be used to "pass through" commonly used attribute name/value pairs with a minimum of code. Attribute names are converted to lower case in the rendered output. Any name/value pairs in the extraHtml String shall take precedence over attribute values.

Parameters:
context - FacesContext for the current request.
component - EditableValueHolder component whose submitted value is to be stored.
writer - ResponseWriter to which the element start should be rendered.
names - List of attribute names to be passed through.
extraHtml - Extra name/value pairs to be rendered.
Throws:
java.io.IOException - if an input/output error occurs

renderHiddenField

public static void renderHiddenField(javax.faces.component.UIComponent component,
                                     javax.faces.context.ResponseWriter writer,
                                     java.lang.String id,
                                     java.lang.String value)
                              throws java.io.IOException
This method will output a hidden field for use with Params and components that need to submit a value through a hidden field. Note: The name of the hidden field will be written as is. For Params no encoding inside the form is done. This is intentional.

Parameters:
writer - The writer to use to write the attributes
id - The identifier of the hidden field. passthrough for this component
Throws:
java.io.IOException

getStyleClasses

public static java.lang.String getStyleClasses(javax.faces.context.FacesContext context,
                                               javax.faces.component.UIComponent component,
                                               java.lang.String styles)

Return a space-separated list of CSS style classes to render for this component, or null for none.

Parameters:
component - UIComponent for which to calculate classes
styles - Additional styles specified by the renderer

renderStyleClass

public static void renderStyleClass(javax.faces.context.FacesContext context,
                                    javax.faces.context.ResponseWriter writer,
                                    javax.faces.component.UIComponent component,
                                    java.lang.String extraStyles)
                             throws java.io.IOException
Throws:
java.io.IOException

renderStyleClass

public static java.lang.String renderStyleClass(javax.faces.context.FacesContext context,
                                                javax.faces.context.ResponseWriter writer,
                                                javax.faces.component.UIComponent component,
                                                java.lang.String styleClass,
                                                java.lang.String extraHtml)
                                         throws java.io.IOException
Helper method to render style classes when name/value pairs are given via an extraHtml String. This method will append the given style to the class name/value pair found in the extraHtml String. The class name/value is removed from the returned extraHtml String so that developers may invoke the writeStringAttributes method without rendering the style class, again.

Parameters:
context - FacesContext for the current request.
component - The UIComponent component to be rendered.
writer - ResponseWriter to which the element start should be rendered.
style - The style to append to the component's styleClass property.
extraHtml - Extra name/value pairs to be rendered.
Throws:
java.io.IOException

getJavascriptId

public static java.lang.String getJavascriptId(javax.faces.context.FacesContext context,
                                               javax.faces.component.UIComponent component)

isPortlet

public static boolean isPortlet(javax.faces.context.FacesContext context)

getLastClientID

public static java.lang.String getLastClientID(javax.faces.context.FacesContext context)
Get the client ID of the last component to have focus.


setLastClientID

public static void setLastClientID(javax.faces.context.FacesContext context,
                                   java.lang.String clientId)
Set the client ID of the last component to have focus.


renderSpacer

public static void renderSpacer(javax.faces.context.ResponseWriter writer,
                                javax.faces.component.UIComponent component,
                                java.lang.String dotSrc,
                                int height,
                                int width)
                         throws java.io.IOException
Helper function to render a transparent spacer image.

Parameters:
writer - The current ResponseWriter
component - The uicomponent
height - The value to use for the image height attribute
width - The value to use for the image width attribute
Throws:
java.io.IOException

renderSpacer

public static void renderSpacer(javax.faces.context.FacesContext context,
                                javax.faces.context.ResponseWriter writer,
                                javax.faces.component.UIComponent component,
                                int height,
                                int width)
                         throws java.io.IOException
Helper function to render a transparent spacer image.

Parameters:
writer - The current ResponseWriter
component - The uicomponent
height - The value to use for the image height attribute
width - The value to use for the image width attribute
Throws:
java.io.IOException

renderJavaScript

public static void renderJavaScript(javax.faces.component.UIComponent component,
                                    Theme theme,
                                    javax.faces.context.FacesContext context,
                                    javax.faces.context.ResponseWriter writer)
                             throws java.io.IOException
Helper function to render theme scripts

Parameters:
context - containing theme
writer - The current ResponseWriter
component - The uicomponent
Throws:
java.io.IOException

renderStyleSheetLink

public static void renderStyleSheetLink(javax.faces.component.UIComponent component,
                                        Theme theme,
                                        javax.faces.context.FacesContext context,
                                        javax.faces.context.ResponseWriter writer)
                                 throws java.io.IOException
Helper function to render theme stylesheet link(s)

Parameters:
context - containing theme
writer - The current ResponseWriter
component - The uicomponent
Throws:
java.io.IOException

renderStyleSheetInline

public static void renderStyleSheetInline(javax.faces.component.UIComponent component,
                                          Theme theme,
                                          javax.faces.context.FacesContext context,
                                          javax.faces.context.ResponseWriter writer)
                                   throws java.io.IOException
Helper function to render theme stylesheet definitions inline

Parameters:
context - containing theme
writer - The current ResponseWriter
component - The uicomponent
Throws:
java.io.IOException

includeJsp

public static void includeJsp(javax.faces.context.FacesContext context,
                              javax.faces.context.ResponseWriter writer,
                              java.lang.String jspURI)
                       throws java.io.IOException
Perform a RequestDispatcher.include of the specified URI jspURI.

The path identifed by jspURI must begin with a <f:subview> tag. The URI must not have as part of its path the FacesServlet mapping. For example if the FacesServlet mapping maps to /faces/* then jspURI must not have /faces/ as part of its path.

If jspUIR is a relative path then the request context path is prepended to it.

Parameters:
context - the FacesContext for this request
writer - the ResponseWrite destination for the rendered output
jspURI - the URI identifying a JSP page to be included.
Throws:
java.io.IOException - if response can't be written or jspURI cannot be included. Real cause is chained.

renderJsInclude

public static boolean renderJsInclude(javax.faces.context.FacesContext context,
                                      javax.faces.component.UIComponent component,
                                      Theme theme,
                                      javax.faces.context.ResponseWriter writer,
                                      java.lang.String includeFile)
                               throws java.io.IOException
Return true if the javascript file identified by includeFile is included. Return false if includeFile is null or there is no javascript file identified by includeFile.

renderJsInclude maintains a RequestMap attribute "sjwuic_jsfile" that resolves to a Map containing files that have previously been included.

Parameters:
context - The current FacesContext
component - The current component being rendered
theme - The Theme to use to locate the Js file
writer - The current ResponseWriter
includeFile - The Js file to include
Throws:
java.io.IOException

renderJsObject

public static boolean renderJsObject(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIComponent component,
                                     javax.faces.context.ResponseWriter writer,
                                     java.lang.String objectName,
                                     java.lang.String jsObjectClass,
                                     java.lang.String arguments)
                              throws java.io.IOException
Throws:
java.io.IOException

getJsObjectName

public static java.lang.String getJsObjectName(javax.faces.context.FacesContext context,
                                               javax.faces.component.UIComponent component,
                                               java.lang.String objectPrefix)

getJsObjectName

public static java.lang.String getJsObjectName(java.lang.String clientId,
                                               java.lang.String objectPrefix)

renderExtraHtmlAttributes

public static void renderExtraHtmlAttributes(javax.faces.context.ResponseWriter writer,
                                             java.lang.String extraHtml)
                                      throws java.io.IOException
Helper method to render extra attributes.

Parameters:
writer - ResponseWriter to which the element end should be rendered
extraHtml - Extra HTML appended to the tag enclosing the header
Throws:
java.io.IOException - if an input/output error occurs

renderURLAttribute

public static void renderURLAttribute(javax.faces.context.FacesContext context,
                                      javax.faces.context.ResponseWriter writer,
                                      javax.faces.component.UIComponent component,
                                      java.lang.String name,
                                      java.lang.String url,
                                      java.lang.String compPropName)
                               throws java.io.IOException
Helper function to render a typical URL

Parameters:
writer - The current ResponseWriter
component - The uicomponent
name - The attribute name of the url to write out
url - The value passed in by the developer for the url
compPropName - The property name of the component's property that specifies this property. Should be null if same as name.
Throws:
java.io.IOException

getParamList

protected static RenderingUtilities.Param[] getParamList(javax.faces.context.FacesContext context,
                                                         javax.faces.component.UIComponent command)

renderSkipLink

public static void renderSkipLink(java.lang.String anchorName,
                                  java.lang.String styleClass,
                                  java.lang.String style,
                                  java.lang.String toolTip,
                                  java.lang.Integer tabIndex,
                                  javax.faces.component.UIComponent component,
                                  javax.faces.context.FacesContext context)
                           throws java.io.IOException
Throws:
java.io.IOException

renderAnchor

public static void renderAnchor(java.lang.String anchorName,
                                javax.faces.component.UIComponent component,
                                javax.faces.context.FacesContext context)
                         throws java.io.IOException
Throws:
java.io.IOException

isVisible

public static boolean isVisible(javax.faces.component.UIComponent component)

Return whether the given UIComponent is "visible". If the property is null, it will return true. Otherwise the value of the property is returned.

Parameters:
component - The UIComponent to check
Returns:
True if the property is null or true, false otherwise.