Class RenderKitUtils
- java.lang.Object
-
- com.sun.faces.renderkit.RenderKitUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRenderKitUtils.PredefinedPostbackParameter
-
Field Summary
Fields Modifier and Type Field Description static StringDEVELOPMENT_STAGE_MESSAGES_IDprotected static LoggerLOGGER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidappendProperty(StringBuilder builder, String name, Object value)static voidappendProperty(StringBuilder builder, String name, Object value, boolean quoteValue)static voidappendQuotedValue(StringBuilder builder, String script)static StringcreateValidECMAIdentifier(String origIdentifier)Replaces all occurrences of-with$_.static StringdetermineContentType(String accept, String serverSupportedTypes, String preferredType)Given an accept String from the client, and aStringof server supported content types, determine the best qualified content type for the client.static RenderKitgetCurrentRenderKit(FacesContext context)Return theRenderKitfor the current request.static UIFormgetForm(UIComponent component, FacesContext context)Utility method to return the client ID of the parent form.static StringgetFormClientId(UIComponent component, FacesContext context)Utility method to return the client ID of the parent form.static StringgetImageSource(FacesContext context, UIComponent component, String attrName)Determine the path value of an image value for a component such as UIGraphic or UICommand.static StringgetParameterName(FacesContext context, String name)If view root is instance of naming container, prepend its container client id to namespace given parameter name.static ResponseStateManagergetResponseStateManager(FacesContext context, String renderKitId)Obtain and return theResponseStateManagerfor the specified #renderKitId.static SelectItemsIterator<SelectItem>getSelectItems(FacesContext context, UIComponent component)Return a List ofSelectIteminstances representing the available options for this component, assembled from the set ofUISelectItemand/orUISelectItemscomponents that are direct children of this component.static voidinstallFacesJsIfNecessary(FacesContext context)Only install the Faces script resource if it doesn't exist.static booleanisFacesJsInstalled(FacesContext context)static booleanisOutputHtml5Doctype(FacesContext context)Returnstrueif the view root associated with the given faces context will be rendered with a HTML5 doctype.static booleanisPartialOrBehaviorAction(FacesContext context, String clientId)static booleanisXml(String contentType)static StringprefixAttribute(String attrName, boolean isXhtml)static StringprefixAttribute(String attrName, ResponseWriter writer)static voidrenderFacesJsIfNecessary(FacesContext context)Renders the Javascript necessary to add and remove request parameters to the current form.static voidrenderFunction(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget)static voidrenderHtmlErrorPage(FacesContext ctx, FacesException fe)static voidrenderOnchange(FacesContext context, UIComponent component, boolean incExec)static voidrenderOnclick(FacesContext context, UIComponent component, Collection<ClientBehaviorContext.Parameter> params, String submitTarget, boolean needsSubmit)static voidrenderPassThruAttributes(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 voidrenderPassThruAttributes(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 voidrenderSelectOnclick(FacesContext context, UIComponent component, boolean incExec)static voidrenderUnhandledMessages(FacesContext ctx)static voidrenderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component)Renders the attributes fromBOOLEAN_ATTRIBUTESusingXHMTLsemantics (i.e., disabled="disabled").static voidrenderXHTMLStyleBooleanAttributes(ResponseWriter writer, UIComponent component, List<String> excludedAttributes)Renders the attributes fromBOOLEAN_ATTRIBUTESusingXHMTLsemantics (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
RenderKitfor the current request.- Parameters:
context- theFacesContextof the current request- Returns:
- the
RenderKitfor the current request.
-
getResponseStateManager
public static ResponseStateManager getResponseStateManager(FacesContext context, String renderKitId) throws FacesException
Obtain and return the
ResponseStateManagerfor the specified #renderKitId.- Parameters:
context- theFacesContextof the current requestrenderKitId-RenderKitID- Returns:
- the
ResponseStateManagerfor 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
SelectIteminstances representing the available options for this component, assembled from the set ofUISelectItemand/orUISelectItemscomponents that are direct children of this component. If there are no such children, an emptyIteratoris returned.- Parameters:
context- TheFacesContextfor 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- ifcontextisnull
-
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 theResponseWriterto 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 theResponseWriterto 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_ATTRIBUTESusingXHMTLsemantics (i.e., disabled="disabled").- Parameters:
writer- writer theResponseWriterto 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_ATTRIBUTESusingXHMTLsemantics (i.e., disabled="disabled").- Parameters:
writer- writer theResponseWriterto be used when writing the attributescomponent- the componentexcludedAttributes- aListof 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
Stringof server supported content types, determine the best qualified content type for the client. If no match is found, or either of the arguments arenull,nullis 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:
trueif 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- theFacesContextfor 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- theFacesContextfor 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- theFacesContextfor 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- theFacesContextfor 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- theFacesContextfor 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)
Returnstrueif the view root associated with the given faces context will be rendered with a HTML5 doctype.- Parameters:
context- Involved faces context.- Returns:
trueif 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)
-
-