是否可以将HTML5组件(<输入类型=“日期">)绑定到托管Bean属性? [英] Is It Possible to Bind An HTML5 Component ( <input type="date">) To A Managed Bean Property?
本文介绍了是否可以将HTML5组件(<输入类型=“日期">)绑定到托管Bean属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用新的HTML5 <input type="date">
并将其值绑定到托管bean:
I would like to use the new HTML5 <input type="date">
and bind its value to a managed bean:
<input type="date" value="#{bean.date}"/>
我想这样做,因为我比PrimeFaces提供的更喜欢它.
I want to do this, because I like this more than the one offered by PrimeFaces.
我该如何实现?
推荐答案
仅从JSF 2.2开始,这是可能的.此功能称为直通元素" .
This is only possible since JSF 2.2. This feature is known as "passthrough elements".
<html xmlns:jsf="http://xmlns.jcp.org/jsf">
...
<input type="date" jsf:value="#{bean.date}" />
或者,使用传递属性" .
<html xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
...
<h:inputText a:type="date" value="#{bean.date}" />
如果您还没有使用JSF 2.2,则可以使用 OmniFaces '
If you're not on JSF 2.2 yet, you could get away with OmniFaces' Html5RenderKit
. This allows you to use new HTML5 attributes on among others <h:inputText>
.
<h:inputText type="date" value="#{bean.date}" />
另请参见
- JSF不会呈现自定义HTML标记属性
- HTML5友好标记JSF 2.2
- OmniFaces
Html5RenderKit
展示页面 - Custom HTML tag attributes are not rendered by JSF
- HTML5 friendly markup in JSF 2.2
- OmniFaces
Html5RenderKit
showcase page
See also
这篇关于是否可以将HTML5组件(<输入类型=“日期">)绑定到托管Bean属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文