public class RenderKitUtils
extends java.lang.Object
A set of utilities for use in RenderKits.
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.logging.Logger |
LOGGER |
| Modifier and Type | Method and Description |
|---|---|
static char[] |
compressJS(java.lang.String JSString)
This is a utility method for compressing multi-lined javascript.
|
static java.lang.String |
createValidECMAIdentifier(java.lang.String origIdentifier)
Replaces all occurrences of
- with $_. |
static java.lang.String |
determineContentType(java.lang.String accept,
java.lang.String serverSupportedTypes,
java.lang.String preferredType)
Given an accept String from the client, and a
String
of server supported content types, determine the best qualified
content type for the client. |
static java.lang.String |
getCommandLinkOnClickScript(java.lang.String formClientId,
java.lang.String commandClientId,
java.lang.String target,
HtmlBasicRenderer.Param[] params)
Returns a string that can be inserted into the
onclick
handler of a command. |
static javax.faces.render.RenderKit |
getCurrentRenderKit(javax.faces.context.FacesContext context)
Return the
RenderKit for the current request. |
static javax.faces.render.ResponseStateManager |
getResponseStateManager(javax.faces.context.FacesContext context,
java.lang.String renderKitId)
Obtain and return the
ResponseStateManager for
the specified #renderKitId. |
static java.util.Iterator<javax.faces.model.SelectItem> |
getSelectItems(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
Return an Iterator over
SelectItem
instances representing the available options for this component,
assembled from the set of UISelectItem
and/or UISelectItems components that are
direct children of this component. |
static boolean |
isXml(java.lang.String contentType) |
static void |
loadSunJsfJs(javax.faces.context.ExternalContext extContext)
Loads the contents of the sunjsf.js file into memory removing any
comments/empty lines it encoutners, and, if enabled, compressing the
result.
|
static java.lang.String |
prefixAttribute(java.lang.String attrName,
boolean isXhtml) |
static java.lang.String |
prefixAttribute(java.lang.String attrName,
javax.faces.context.ResponseWriter writer) |
static void |
renderFormInitScript(javax.faces.context.ResponseWriter writer,
javax.faces.context.FacesContext context)
Renders the Javascript necessary to add and remove request
parameters to the current form.
|
static void |
renderPassThruAttributes(javax.faces.context.FacesContext context,
javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component)
Render any "passthru" attributes, where we simply just output the
raw name and value of the attribute.
|
static void |
renderPassThruAttributes(javax.faces.context.FacesContext context,
javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component,
java.lang.String[] excludes)
Render any "passthru" attributes, where we simply just output the
raw name and value of the attribute.
|
static void |
renderXHTMLStyleBooleanAttributes(javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component)
Renders the attributes from
BOOLEAN_ATTRIBUTES
using XHMTL semantics (i.e., disabled="disabled"). |
static void |
renderXHTMLStyleBooleanAttributes(javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component,
java.lang.String[] excludes)
Renders the attributes from
BOOLEAN_ATTRIBUTES
using XHMTL semantics (i.e., disabled="disabled"). |
static void |
writeSunJS(javax.faces.context.FacesContext context,
java.io.Writer writer)
Return the implementation JavaScript.
|
public static javax.faces.render.RenderKit getCurrentRenderKit(javax.faces.context.FacesContext context)
Return the RenderKit for the current request.
context - the FacesContext of the current requestRenderKit for the current request.public static javax.faces.render.ResponseStateManager getResponseStateManager(javax.faces.context.FacesContext context,
java.lang.String renderKitId)
throws javax.faces.FacesException
Obtain and return the ResponseStateManager for
the specified #renderKitId.
context - the FacesContext of the current requestrenderKitId - RenderKit IDResponseStateManager for the specified
#renderKitIdjavax.faces.FacesException - if an exception occurs while trying
to obtain the ResponseStateManagerpublic static java.util.Iterator<javax.faces.model.SelectItem> getSelectItems(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
Return an Iterator over SelectItem
instances representing the available options for this component,
assembled from the set of UISelectItem
and/or UISelectItems components that are
direct children of this component. If there are no such children, an
empty Iterator is returned.
context - The FacesContext for the current request.
If null, the UISelectItems behavior will not work.component - the componentjava.lang.IllegalArgumentException - if context
is nullpublic static void renderPassThruAttributes(javax.faces.context.FacesContext context,
javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component)
throws java.io.IOException
Render any "passthru" attributes, where we simply just output the raw name and value of the attribute. This method is aware of the set of HTML4 attributes that fall into this bucket. Examples are all the javascript attributes, alt, rows, cols, etc.
This version of the method allows the user to exclude certain attributes from being processed.
context - context the FacesContext of the current requestwriter - writer the ResponseWriter to be used when writing
the attributescomponent - the componentjava.io.IOException - if an error occurs writing the attributesrenderPassThruAttributes(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, javax.faces.component.UIComponent, String[])public static void renderPassThruAttributes(javax.faces.context.FacesContext context,
javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component,
java.lang.String[] excludes)
throws java.io.IOException
Render any "passthru" attributes, where we simply just output the raw name and value of the attribute. This method is aware of the set of HTML4 attributes that fall into this bucket. Examples are all the javascript attributes, alt, rows, cols, etc.
This version of the method allows the user to exclude certain attributes from being processed.
context - context the FacesContext of the current requestwriter - writer the ResponseWriter to be used when writing
the attributescomponent - the componentexcludes - any attributes that should be excluded from writing to
the responsejava.io.IOException - if an error occurs writing the attributespublic static java.lang.String prefixAttribute(java.lang.String attrName,
javax.faces.context.ResponseWriter writer)
public static java.lang.String prefixAttribute(java.lang.String attrName,
boolean isXhtml)
public static void renderXHTMLStyleBooleanAttributes(javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component)
throws java.io.IOException
Renders the attributes from BOOLEAN_ATTRIBUTES
using XHMTL semantics (i.e., disabled="disabled").
writer - writer the ResponseWriter to be used when writing
the attributescomponent - the componentjava.io.IOException - if an error occurs writing the attributespublic static void renderXHTMLStyleBooleanAttributes(javax.faces.context.ResponseWriter writer,
javax.faces.component.UIComponent component,
java.lang.String[] excludes)
throws java.io.IOException
Renders the attributes from BOOLEAN_ATTRIBUTES
using XHMTL semantics (i.e., disabled="disabled").
This version of the method allows the user to exclude certain attributes from being processed.
writer - writer the ResponseWriter to be used when writing
the attributescomponent - the componentexcludes - any attributes that should be excluded from writing to
the responsejava.io.IOException - if an error occurs writing the attributespublic static java.lang.String determineContentType(java.lang.String accept,
java.lang.String serverSupportedTypes,
java.lang.String preferredType)
Given an accept String from the client, and a String
of server supported content types, determine the best qualified
content type for the client. If no match is found, or either of the
arguments are null, null is returned.
accept - The client accept StringserverSupportedTypes - The types that the server supportspreferredType - The preferred content type if another type is found
with the same highest quality factor.Stringpublic static boolean isXml(java.lang.String contentType)
contentType - the content type in questiontrue if the content type is a known XML-based
content type, otherwise, falsepublic static java.lang.String createValidECMAIdentifier(java.lang.String origIdentifier)
Replaces all occurrences of - with $_.
origIdentifier - the original identifer that needs to be
'ECMA-ized'public static void renderFormInitScript(javax.faces.context.ResponseWriter writer,
javax.faces.context.FacesContext context)
throws java.io.IOException
Renders the Javascript necessary to add and remove request parameters to the current form.
writer - the ResponseWritercontext - the FacesContext for the current requestjava.io.IOException - if an error occurs writing to the responsepublic static java.lang.String getCommandLinkOnClickScript(java.lang.String formClientId,
java.lang.String commandClientId,
java.lang.String target,
HtmlBasicRenderer.Param[] params)
Returns a string that can be inserted into the onclick
handler of a command. This string will add all request parameters
as well as the client ID of the activated command to the form as
hidden input parameters, update the target of the link if necessary,
and handle the form submission. The content of SUN_JSF_JS
must be rendered prior to using this method.
formClientId - the client ID of the formcommandClientId - the client ID of the commandtarget - params - the nested parameters, if any @return a String suitable for the onclick handler
of a commandpublic static char[] compressJS(java.lang.String JSString)
This is a utility method for compressing multi-lined javascript.
In the case of SUN_JSF_JS it offers about a 47% decrease
in length.
For our purposes, compression is just trimming each line and then writing it out. It's pretty simplistic, but it works.
JSString - the string to compresspublic static void writeSunJS(javax.faces.context.FacesContext context,
java.io.Writer writer)
throws java.io.IOException
Return the implementation JavaScript. If compression is enabled, the result will be compressed.
context - - the FacesContext for the current requestwriter - - the Writer to write the JS tojava.io.IOExceptionpublic static void loadSunJsfJs(javax.faces.context.ExternalContext extContext)
Loads the contents of the sunjsf.js file into memory removing any comments/empty lines it encoutners, and, if enabled, compressing the result.
This method should only be called when the application is being initialized.Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.