Top Description Inners Fields Constructors Methods
com.sun.faces.renderkit

public Class RenderKitUtils

extends Object
Class Inheritance
Static Imports
com.sun.faces.renderkit.RenderKitUtils.PredefinedPostbackParameter.BEHAVIOR_EVENT_PARAM, .RenderKitUtils.PredefinedPostbackParameter.BEHAVIOR_SOURCE_PARAM, .RenderKitUtils.PredefinedPostbackParameter.PARTIAL_EVENT_PARAM, jakarta.faces.application.ResourceHandler.FACES_SCRIPT_LIBRARY_NAME, .ResourceHandler.FACES_SCRIPT_RESOURCE_NAME

A set of utilities for use in RenderKits.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
public static enum

Field Summary

Modifier and TypeField and Description
private static final String
ATTRIBUTES_THAT_ARE_SET_KEY

Implementation Note

This must be kept in sync with the Key in UIComponentBase$AttributesMap and HtmlComponentGenerator.

private static final String[]
BOOLEAN_ATTRIBUTES

Boolean attributes to be rendered using XHMTL semantics.

private static final String
CONTENT_TYPE_DELIMITER

The character that is used to delimit content types in an accept String.

private static final String
CONTENT_TYPE_SUBTYPE_DELIMITER

The character that is used to delimit the type and subtype portions of a content type in an accept String.

public static final String
protected static final Logger
private static final int
MAX_CONTENT_TYPE_PARTS

The maximum number of content type parts.

private static final String
OPTIMIZED_PACKAGE

This represents the base package that can leverage the attributesThatAreSet List for optimized attribute rendering.

private static final String
VIEW_ROOT_ATTRIBUTES_DOCTYPE_KEY

UIViewRoot attribute key of a boolean value which remembers whether the view will be rendered with a HTML5 doctype.

private static final String
XHTML_ATTR_PREFIX

The prefix to append to certain attributes when renderking XHTML Transitional content.

private static final String[]
XHTML_PREFIX_ATTRIBUTES

An array of attributes that must be prefixed by XHTML_ATTR_PREFIX when rendering XHTML Transitional content.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean
public static void
appendProperty(StringBuilder builder, String name, Object value)

public static void
appendProperty(StringBuilder builder, String name, Object value, boolean quoteValue)

public static void
private static void
private static String[][]

Returns:

an two dimensional array containing content-type/quality info
buildTypeArrayFromString
(String
An accept String
accept
)

This method builds a two element array structure as follows: Example: Given the following accept string: text/html; level=1, text/plain; q=0.5 [0][0] 1 (quality is 1 if none specified) [0][1] "text" (type) [0][2] "html; level=1" (subtype) [0][3] 1 (level, if specified; null if not) [1][0] .5 [1][1] "text" [1][2] "plain" [1][3] (level, if specified; null if not) The array is used for comparison purposes in the findMatch method.

private static boolean

Returns:

true if the component is within the jakarta.faces.component or jakarta.faces.component.html packages, otherwise return false
canBeOptimized
(UIComponent
the UIComponent in question
component
,
Map<String, List<ClientBehavior>> behaviors)

private static ClientBehaviorContext
private static UIComponent
public static String

Returns:

an ECMA valid identifer
createValidECMAIdentifier
(String
the original identifer that needs to be 'ECMA-ized'
origIdentifier
)

Replaces all occurrences of - with $_.

public static String

Returns:

The content type String
determineContentType
(String
The client accept String
accept
,
String
The types that the server supports
serverSupportedTypes
,
String
The preferred content type if another type is found with the same highest quality factor.
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.

private static String[][]

Returns:

An array containing the parts of the preferred content type for the client. The information is stored as outlined in @{link #buildTypeArrayFromString}.
findMatch
(String[][]
An array of accept String information for the client built from @{link #buildTypeArrayFromString}.
clientContentTypes
,
String[][]
An array of accept String information for the server supported types built from @{link #buildTypeArrayFromString}.
serverSupportedContentTypes
,
String[][]
An array of preferred content type information.
preferredContentType
)

For each server supported type, compare client (browser) specified types.

private static String
getChainedHandler(FacesContext context, UIComponent component, List<ClientBehavior> behaviors, Collection<ClientBehaviorContext.Parameter> params, String behaviorEventName, String userHandler, String submitTarget, boolean needsSubmit)

private static List<ClientBehavior>
getClientBehaviors(UIComponent component, String behaviorEventName)

public static RenderKit

Returns:

the RenderKit for the current request.
getCurrentRenderKit
(FacesContext
the FacesContext of the current request
context
)

Return the RenderKit for the current request.

public static UIForm

Returns:

the parent form, if any
getForm
(UIComponent
typically a command component
component
,
FacesContext
the FacesContext for the current request
context
)

Utility method to return the client ID of the parent form.

public static String

Returns:

the client ID of the parent form, if any
getFormClientId
(UIComponent
typically a command component
component
,
FacesContext
the FacesContext for the current request
context
)

Utility method to return the client ID of the parent form.

private static RenderKitUtils.HandlerType
getHandlerType(List<ClientBehavior> behaviors, Collection<ClientBehaviorContext.Parameter> params, String userHandler, boolean needsSubmit, boolean includeExec)

public static String

Returns:

the encoded path to the image source
getImageSource
(FacesContext
the FacesContext for the current request.
context
,
UIComponent
the component to obtain the image information from
component
,
String
the attribute name that needs to be queried if the name and library attributes are not specified
attrName
)

Determine the path value of an image value for a component such as UIGraphic or UICommand.

private static String
public static String

Returns:

The request parameter name, if necessary namespaced.
getParameterName
(FacesContext
Involved faces context.
context
,
String
Request parameter name.
name
)

If view root is instance of naming container, prepend its container client id to namespace given parameter name.

public static ResponseStateManager

Returns:

the ResponseStateManager for the specified #renderKitId
getResponseStateManager
(FacesContext
the FacesContext of the current request
context
,
String renderKitId)

Obtain and return the ResponseStateManager for the specified #renderKitId.

public static SelectItemsIterator<SelectItem>

Returns:

a List of the select items for the specified component
getSelectItems
(FacesContext
The jakarta.faces.context.FacesContext for the current request. If null, the UISelectItems behavior will not work.
context
,
UIComponent
the component
component
)

Return a List of jakarta.faces.model.SelectItem instances representing the available options for this component, assembled from the set of jakarta.faces.component.UISelectItem and/or jakarta.faces.component.UISelectItems components that are direct children of this component.

private static String
private static String
getSingleBehaviorHandler(FacesContext context, UIComponent component, ClientBehavior behavior, Collection<ClientBehaviorContext.Parameter> params, String behaviorEventName, String submitTarget, boolean needsSubmit)

private static String
getSubmitHandler(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget, boolean preventDefault)

public static void
installFacesJsIfNecessary(FacesContext
the FacesContext for the current request
context
)

Only install the Faces script resource if it doesn't exist.

private static boolean
isBehaviorEventAttribute(Attribute attr, String behaviorEventName)

private static boolean

Returns:

true if the attribute name is not in the exclude list.
isExcludedAttribute
(String
the attribute name that is to be tested for exclusion
attributeName
,
List<String>
the list of attribute names that are to be excluded from rendering
excludedAttributes
)

This method expects a List of attribute names that are to be excluded from rendering.

public static boolean
public static boolean

Returns:

true if the view root associated with the given faces context will be rendered with a HTML5 doctype.
isOutputHtml5Doctype
(FacesContext
Involved faces context.
context
)

Returns true if the view root associated with the given faces context will be rendered with a HTML5 doctype.

public static boolean
private static boolean
public static boolean

Returns:

true if the content type is a known XML-based content type, otherwise, false
isXml
(String
the content type in question
contentType
)

private static void
mapAttributes(UIComponent component, AjaxBehavior behavior, String... attributeNames)

public static String
prefixAttribute(final String attrName, final ResponseWriter writer)

public static String
prefixAttribute(final String attrName, boolean isXhtml)

public static void
renderFacesJsIfNecessary(FacesContext
the FacesContext for the current request
context
)

Renders the Javascript necessary to add and remove request parameters to the current form.

public static void
private static void
renderHandler(FacesContext
the FacesContext for this request.
context
,
UIComponent
the UIComponent that we are rendering
component
,
Collection<ClientBehaviorContext.Parameter>
any parameters that should be included by "submitting" scripts.
params
,
String
the name of the handler attribute to render (eg. "onclick" or "ommouseover")
handlerName
,
Object
the user-specified value for the handler attribute
handlerValue
,
String
the name of the behavior event that corresponds to this handler (eg. "action" or "mouseover").
behaviorEventName
,
String submitTarget, boolean
indicates whether the mojarra.cljs() "submit" script is required by the component. Most components do not need this, either because they submit themselves (eg. commandButton), or because they do not perform submits (eg. non-command components). This flag is mainly here for the commandLink case, where we need to render the submit script to make the link submit.
needsSubmit
,
boolean includeExec)

Renders a handler script, which may require chaining together the user-specified event handler, any scripts required by attached Behaviors, and also possibly the mojarra.cljs() "submit" script.

public static void
public static void
renderOnchange(FacesContext context, UIComponent component, boolean incExec)

public static void
renderOnclick(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget, boolean needsSubmit)

public static void
renderPassThruAttributes(FacesContext
the FacesContext for this request
context
,
ResponseWriter
writer the jakarta.faces.context.ResponseWriter to be used when writing the attributes
writer
,
UIComponent
the component
component
,
Attribute[]
an array of attributes to be processed
attributes
)

Render any "passthru" attributes, where we simply just output the raw name and value of the attribute.

public static void
renderPassThruAttributes(FacesContext
the FacesContext for this request
context
,
ResponseWriter
writer the jakarta.faces.context.ResponseWriter to be used when writing the attributes
writer
,
UIComponent
the component
component
,
Attribute[]
an array of attributes to be processed
attributes
,
Map<String, List<ClientBehavior>>
the behaviors for this component, or null if component is not a ClientBehaviorHolder
behaviors
)

Render any "passthru" attributes, where we simply just output the raw name and value of the attribute.

private static void
renderPassThruAttributesOptimized(FacesContext
the FacesContext of the current request
context
,
ResponseWriter
the current writer
writer
,
UIComponent
the component whose attributes we're rendering
component
,
Attribute[]
an array of pass-through attributes supported by this component
knownAttributes
,
List<String>
a List of attributes that have been set on the provided component
setAttributes
,
Map<String, List<ClientBehavior>>
the non-null behaviors map for this request.
behaviors
)

For each attribute in setAttributes, perform a binary search against the array of knownAttributes If a match is found and the value is not null, render the attribute.

private static void
renderPassThruAttributesUnoptimized(FacesContext
the FacesContext of the current request
context
,
ResponseWriter
the current writer
writer
,
UIComponent
the component whose attributes we're rendering
component
,
Attribute[]
an array of pass-through attributes supported by this component
knownAttributes
,
Map<String, List<ClientBehavior>>
the non-null behaviors map for this request.
behaviors
)

Loops over all known attributes and attempts to render each one.

public static void
renderSelectOnclick(FacesContext context, UIComponent component, boolean incExec)

public static void
public static void
renderXHTMLStyleBooleanAttributes(ResponseWriter
writer the ResponseWriter to be used when writing the attributes
writer
,
UIComponent
the component
component
)

Renders the attributes from BOOLEAN_ATTRIBUTES using XHMTL semantics (i.e., disabled="disabled").

public static void
renderXHTMLStyleBooleanAttributes(ResponseWriter
writer the ResponseWriter to be used when writing the attributes
writer
,
UIComponent
the component
component
,
List<String>
a List of attributes that are to be excluded from rendering
excludedAttributes
)

Renders the attributes from BOOLEAN_ATTRIBUTES using XHMTL semantics (i.e., disabled="disabled").

private static boolean

Returns:

true if and only if #attributeVal is an instance of a wrapper for a primitive type and its value is equal to the default value for that type as given in the specification.
shouldRenderAttribute
(Object
the attribute value
attributeVal
)

Determines if an attribute should be rendered based on the specified #attributeVal.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait