org.omnifaces.renderkit
Class Html5RenderKit

java.lang.Object
  extended by javax.faces.render.RenderKit
      extended by javax.faces.render.RenderKitWrapper
          extended by org.omnifaces.renderkit.Html5RenderKit
All Implemented Interfaces:
javax.faces.FacesWrapper<javax.faces.render.RenderKit>

public class Html5RenderKit
extends javax.faces.render.RenderKitWrapper

This HTML5 render kit adds support for HTML5 specific attributes which are unsupported by the JSF UIForm, UIInput and UICommand components. So far in JSF 2.0 and 2.1 only the autocomplete attribute is supported in UIInput components. All other attributes are by design ignored by the JSF standard HTML render kit. This HTML5 render kit supports the following HTML5 specific attributes:

Note: the list attribute expects a <datalist> element which needs to be coded in "plain vanilla" HTML (and is currently, June 2012, only supported in Firefox 4 and Opera 11). See also HTML5 tutorial.

Installation

Refer the documentation of Html5RenderKitFactory how to setup it.

Configuration

You can also configure additional passthrough attributes via the "org.omnifaces.HTML5_RENDER_KIT_PASSTHROUGH_ATTRIBUTES" context parameter, wherein the passthrough attributes are been specified in semicolon-separated com.example.SomeComponent=attr1,attr2,attr3 key=value pairs. The key represents the fully qualified name of a class whose Class.isInstance(Object) must return true for the particular component and the value represents the commaseparated string of names of passthrough attributes. Here's an example:

 <context-param>
   <param-name>org.omnifaces.HTML5_RENDER_KIT_PASSTHROUGH_ATTRIBUTES</param-name>
   <param-value>
     javax.faces.component.UIInput=x-webkit-speech,x-webkit-grammar;
     javax.faces.component.UIComponent=contenteditable,draggable
   </param-value>
 </context-param>
 

JSF 2.2 notice

Noted should be that JSF 2.2 will support defining custom attributes directly in the view via the new http://java.sun.com/jsf/passthrough namespace or the <f:passThroughAttribute> tag.

 <html ... xmlns:p="http://java.sun.com/jsf/passthrough">
 ...
 <h:inputText ... p:autofocus="true" />
 
(you may want to use a instead of p as namespace prefix to avoid clash with PrimeFaces default namespace)

Or:

 <h:inputText ...>
   <f:passThroughAttribute name="autofocus" value="true" />
 </h:inputText>
 

Since:
1.1
Author:
Bauke Scholtz

Field Summary
static java.lang.String PARAM_NAME_PASSTHROUGH_ATTRIBUTES
          The context parameter name to specify additional passthrough attributes.
 
Constructor Summary
Html5RenderKit(javax.faces.render.RenderKit wrapped)
          Construct a new HTML5 render kit around the given wrapped render kit.
 
Method Summary
 javax.faces.context.ResponseWriter createResponseWriter(java.io.Writer writer, java.lang.String contentTypeList, java.lang.String characterEncoding)
          Returns a new HTML5 response writer which in turn wraps the default response writer.
 javax.faces.render.RenderKit getWrapped()
           
 
Methods inherited from class javax.faces.render.RenderKitWrapper
addClientBehaviorRenderer, addRenderer, createResponseStream, getClientBehaviorRenderer, getClientBehaviorRendererTypes, getComponentFamilies, getRenderer, getRendererTypes, getResponseStateManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_NAME_PASSTHROUGH_ATTRIBUTES

public static final java.lang.String PARAM_NAME_PASSTHROUGH_ATTRIBUTES
The context parameter name to specify additional passthrough attributes.

See Also:
Constant Field Values
Constructor Detail

Html5RenderKit

public Html5RenderKit(javax.faces.render.RenderKit wrapped)
Construct a new HTML5 render kit around the given wrapped render kit.

Parameters:
wrapped - The wrapped render kit.
Method Detail

createResponseWriter

public javax.faces.context.ResponseWriter createResponseWriter(java.io.Writer writer,
                                                               java.lang.String contentTypeList,
                                                               java.lang.String characterEncoding)
Returns a new HTML5 response writer which in turn wraps the default response writer.

Overrides:
createResponseWriter in class javax.faces.render.RenderKitWrapper

getWrapped

public javax.faces.render.RenderKit getWrapped()
Specified by:
getWrapped in interface javax.faces.FacesWrapper<javax.faces.render.RenderKit>
Overrides:
getWrapped in class javax.faces.render.RenderKitWrapper