Class RenderKitUtils
- java.lang.Object
-
- com.sun.faces.renderkit.RenderKitUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RenderKitUtils.PredefinedPostbackParameter
-
Field Summary
Fields Modifier and Type Field Description static String
DEVELOPMENT_STAGE_MESSAGES_ID
protected static Logger
LOGGER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendProperty(StringBuilder builder, String name, Object value)
static void
appendProperty(StringBuilder builder, String name, Object value, boolean quoteValue)
static void
appendQuotedValue(StringBuilder builder, String script)
static String
createValidECMAIdentifier(String origIdentifier)
Replaces all occurrences of-
with$_
.static String
determineContentType(String accept, String serverSupportedTypes, String preferredType)
Given an accept String from the client, and aString
of server supported content types, determine the best qualified content type for the client.static RenderKit
getCurrentRenderKit(FacesContext context)
Return theRenderKit
for the current request.static UIForm
getForm(UIComponent component, FacesContext context)
Utility method to return the client ID of the parent form.static String
getFormClientId(UIComponent component, FacesContext context)
Utility method to return the client ID of the parent form.static String
getImageSource(FacesContext context, UIComponent component, String attrName)
Determine the path value of an image value for a component such as UIGraphic or UICommand.static String
getParameterName(FacesContext context, String name)
If view root is instance of naming container, prepend its container client id to namespace given parameter name.static ResponseStateManager
getResponseStateManager(FacesContext context, String renderKitId)
Obtain and return theResponseStateManager
for the specified #renderKitId.static SelectItemsIterator<SelectItem>
getSelectItems(FacesContext context, UIComponent component)
Return a List ofSelectItem
instances representing the available options for this component, assembled from the set ofUISelectItem
and/orUISelectItems
components that are direct children of this component.static void
installFacesJsIfNecessary(FacesContext context)
Only install the Faces script resource if it doesn't exist.static boolean
isFacesJsInstalled(FacesContext context)
static boolean
isOutputHtml5Doctype(FacesContext context)
Returnstrue
if the view root associated with the given faces context will be rendered with a HTML5 doctype.static boolean
isPartialOrBehaviorAction(FacesContext context, String clientId)
static boolean
isXml(String contentType)
static String
prefixAttribute(String attrName, boolean isXhtml)
static String
prefixAttribute(String attrName, ResponseWriter writer)
static void
renderFacesJsIfNecessary(FacesContext context)
Renders the Javascript necessary to add and remove request parameters to the current form.static void
renderFunction(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget)
static void
renderHtmlErrorPage(FacesContext ctx, FacesException fe)
static void
renderOnchange(FacesContext context, UIComponent component, boolean incExec)
static void
renderOnclick(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget, boolean needsSubmit)
static void
renderPassThruAttributes(FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] attributes)
Render any "passthru" attributes, where we simply just output the raw name and value of the attribute.static void
renderPassThruAttributes(FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] attributes, Map<String,List<ClientBehavior>> behaviors)
Render any "passthru" attributes, where we simply just output the raw name and value of the attribute.static void
renderSelectOnclick(FacesContext context, UIComponent component, boolean incExec)
static void
renderUnhandledMessages(FacesContext ctx)
static void
renderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component)
Renders the attributes fromBOOLEAN_ATTRIBUTES
usingXHMTL
semantics (i.e., disabled="disabled").static void
renderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component, List<String> excludedAttributes)
Renders the attributes fromBOOLEAN_ATTRIBUTES
usingXHMTL
semantics (i.e., disabled="disabled").
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
-
DEVELOPMENT_STAGE_MESSAGES_ID
public static final String DEVELOPMENT_STAGE_MESSAGES_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentRenderKit
public static RenderKit getCurrentRenderKit(FacesContext context)
Return the
RenderKit
for the current request.- Parameters:
context
- theFacesContext
of the current request- Returns:
- the
RenderKit
for the current request.
-
getResponseStateManager
public static ResponseStateManager getResponseStateManager(FacesContext context, String renderKitId) throws FacesException
Obtain and return the
ResponseStateManager
for the specified #renderKitId.- Parameters:
context
- theFacesContext
of the current requestrenderKitId
-RenderKit
ID- Returns:
- the
ResponseStateManager
for the specified #renderKitId - Throws:
FacesException
- if an exception occurs while trying to obtain theResponseStateManager
-
getSelectItems
public static SelectItemsIterator<SelectItem> getSelectItems(FacesContext context, UIComponent component)
Return a List of
SelectItem
instances representing the available options for this component, assembled from the set ofUISelectItem
and/orUISelectItems
components that are direct children of this component. If there are no such children, an emptyIterator
is returned.- Parameters:
context
- TheFacesContext
for the current request. If null, the UISelectItems behavior will not work.component
- the component- Returns:
- a List of the select items for the specified component
- Throws:
IllegalArgumentException
- ifcontext
isnull
-
renderPassThruAttributes
public static void renderPassThruAttributes(FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] attributes) throws 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.
- Parameters:
context
- the FacesContext for this requestwriter
- writer theResponseWriter
to be used when writing the attributescomponent
- the componentattributes
- an array of attributes to be processed- Throws:
IOException
- if an error occurs writing the attributes
-
renderPassThruAttributes
public static void renderPassThruAttributes(FacesContext context, ResponseWriter writer, UIComponent component, Attribute[] attributes, Map<String,List<ClientBehavior>> behaviors) throws 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.
- Parameters:
context
- the FacesContext for this requestwriter
- writer theResponseWriter
to be used when writing the attributescomponent
- the componentattributes
- an array of attributes to be processedbehaviors
- the behaviors for this component, or null if component is not a ClientBehaviorHolder- Throws:
IOException
- if an error occurs writing the attributes
-
renderOnchange
public static void renderOnchange(FacesContext context, UIComponent component, boolean incExec) throws IOException
- Throws:
IOException
-
renderSelectOnclick
public static void renderSelectOnclick(FacesContext context, UIComponent component, boolean incExec) throws IOException
- Throws:
IOException
-
renderOnclick
public static void renderOnclick(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget, boolean needsSubmit) throws IOException
- Throws:
IOException
-
renderFunction
public static void renderFunction(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget) throws IOException
- Throws:
IOException
-
prefixAttribute
public static String prefixAttribute(String attrName, ResponseWriter writer)
-
renderXHTMLStyleBooleanAttributes
public static void renderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component) throws IOException
Renders the attributes from
BOOLEAN_ATTRIBUTES
usingXHMTL
semantics (i.e., disabled="disabled").- Parameters:
writer
- writer theResponseWriter
to be used when writing the attributescomponent
- the component- Throws:
IOException
- if an error occurs writing the attributes
-
renderXHTMLStyleBooleanAttributes
public static void renderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component, List<String> excludedAttributes) throws IOException
Renders the attributes from
BOOLEAN_ATTRIBUTES
usingXHMTL
semantics (i.e., disabled="disabled").- Parameters:
writer
- writer theResponseWriter
to be used when writing the attributescomponent
- the componentexcludedAttributes
- aList
of attributes that are to be excluded from rendering- Throws:
IOException
- if an error occurs writing the attributes
-
determineContentType
public static String determineContentType(String accept, String serverSupportedTypes, 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 arenull
,null
is returned.- Parameters:
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.- Returns:
- The content type
String
-
isXml
public static boolean isXml(String contentType)
- Parameters:
contentType
- the content type in question- Returns:
true
if the content type is a known XML-based content type, otherwise,false
-
createValidECMAIdentifier
public static String createValidECMAIdentifier(String origIdentifier)
Replaces all occurrences of
-
with$_
.- Parameters:
origIdentifier
- the original identifer that needs to be 'ECMA-ized'- Returns:
- an ECMA valid identifer
-
installFacesJsIfNecessary
public static void installFacesJsIfNecessary(FacesContext context)
Only install the Faces script resource if it doesn't exist. The resource component will be installed with the target "head".
- Parameters:
context
- theFacesContext
for the current request
-
renderFacesJsIfNecessary
public static void renderFacesJsIfNecessary(FacesContext context) throws IOException
Renders the Javascript necessary to add and remove request parameters to the current form.
- Parameters:
context
- theFacesContext
for the current request- Throws:
IOException
- if an error occurs writing to the response
-
isFacesJsInstalled
public static boolean isFacesJsInstalled(FacesContext context)
-
renderUnhandledMessages
public static void renderUnhandledMessages(FacesContext ctx)
-
renderHtmlErrorPage
public static void renderHtmlErrorPage(FacesContext ctx, FacesException fe)
-
isPartialOrBehaviorAction
public static boolean isPartialOrBehaviorAction(FacesContext context, String clientId)
-
getFormClientId
public static String getFormClientId(UIComponent component, FacesContext context)
Utility method to return the client ID of the parent form.
- Parameters:
component
- typically a command componentcontext
- theFacesContext
for the current request- Returns:
- the client ID of the parent form, if any
-
getForm
public static UIForm getForm(UIComponent component, FacesContext context)
Utility method to return the client ID of the parent form.
- Parameters:
component
- typically a command componentcontext
- theFacesContext
for the current request- Returns:
- the parent form, if any
-
getImageSource
public static String getImageSource(FacesContext context, UIComponent component, String attrName)
Determine the path value of an image value for a component such as UIGraphic or UICommand.
- Parameters:
context
- theFacesContext
for the current request.component
- the component to obtain the image information fromattrName
- the attribute name that needs to be queried if the name and library attributes are not specified- Returns:
- the encoded path to the image source
-
getParameterName
public static String getParameterName(FacesContext context, String name)
If view root is instance of naming container, prepend its container client id to namespace given parameter name.- Parameters:
context
- Involved faces context.name
- Request parameter name.- Returns:
- The request parameter name, if necessary namespaced.
-
isOutputHtml5Doctype
public static boolean isOutputHtml5Doctype(FacesContext context)
Returnstrue
if the view root associated with the given faces context will be rendered with a HTML5 doctype.- Parameters:
context
- Involved faces context.- Returns:
true
if the view root associated with the given faces context will be rendered with a HTML5 doctype.
-
appendProperty
public static void appendProperty(StringBuilder builder, String name, Object value)
-
appendProperty
public static void appendProperty(StringBuilder builder, String name, Object value, boolean quoteValue)
-
appendQuotedValue
public static void appendQuotedValue(StringBuilder builder, String script)
-
-