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:
UIForm
: autocomplete
UISelectBoolean
, UISelectOne
and UISelectMany
:
autofocus
HtmlInputTextarea
: autofocus
maxlength
placeholder
spellcheck
wrap
HtmlInputText
: type
(supported values are
text
(default), search
, email
, url
, tel
,
range
, number
and date
)autofocus
list
pattern
placeholder
spellcheck
min
max
step
type
of range
, number
and date
)HtmlInputSecret
: autofocus
pattern
placeholder
HtmlCommandButton
: autofocus
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.
Refer the documentation of Html5RenderKitFactory
how to setup it.
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>
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>
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_NAME_PASSTHROUGH_ATTRIBUTES
The context parameter name to specify additional passthrough attributes.
|
Constructor and Description |
---|
Html5RenderKit(javax.faces.render.RenderKit wrapped)
Construct a new HTML5 render kit around the given wrapped render kit.
|
Modifier and Type | Method and Description |
---|---|
javax.faces.context.ResponseWriter |
createResponseWriter(Writer writer,
String contentTypeList,
String characterEncoding)
Returns a new HTML5 response writer which in turn wraps the default response writer.
|
javax.faces.render.RenderKit |
getWrapped() |
public static final String PARAM_NAME_PASSTHROUGH_ATTRIBUTES
public Html5RenderKit(javax.faces.render.RenderKit wrapped)
wrapped
- The wrapped render kit.public javax.faces.context.ResponseWriter createResponseWriter(Writer writer, String contentTypeList, String characterEncoding)
createResponseWriter
in class javax.faces.render.RenderKitWrapper
public javax.faces.render.RenderKit getWrapped()
getWrapped
in interface javax.faces.FacesWrapper<javax.faces.render.RenderKit>
getWrapped
in class javax.faces.render.RenderKitWrapper
Copyright © 2012–2014 OmniFaces. All rights reserved.