是否可以将HTML5组件(<输入类型=“日期">)绑定到托管Bean属性? [英] Is It Possible to Bind An HTML5 Component ( <input type="date">) To A Managed Bean Property?

查看:239
本文介绍了是否可以将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}" />

另请参见

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆