JSF Converter f:convertDateTime如何工作? [英] How the JSF Converter f:convertDateTime works?

查看:72
本文介绍了JSF Converter f:convertDateTime如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 JSF Converter

f:convertDateTime

我在这种情况下使用此转换器(bean.date表示Java类java.util.Date):

I i use this converter in this context (bean.date represent the Java class java.util.Date):

<h:inputText id="date" value="#{bean.date}" label="Enter Date" >
   <f:convertDateTime pattern="d-M-yyyy" />
</h:inputText>

仅在网络服务器的响应中,使此转换器仅为用户设置xhtml页面格式?

Works this converter only to format xhtml page for the user in the response from the webserver?

或者如果请求已发送到Web服务器并以模式格式d-M-yyyy存储在支持bean中,则输入的值将采用模式d-M-yyyy格式化吗?

Or will the entered value formatted with the pattern d-M-yyyy, if the request was send to the webserver and stored in the backing bean with the pattern format d-M-yyyy?

是否可以在不使用任何f:convertDateTime的情况下将xhtml页面中的某些Date值插入到后备bean中?或者这是绝对必要的吗?

Is it possivle to insert some Date values from xhtml page into backing bean without using any kind of f:convertDateTime or is this absolutly necessary?

格里茨 Marwief

Greetz Marwief

推荐答案

转换器用于两种方式的转换,这是必需的,因为有很多写入日期的方式.

The converter is used for conversions both ways and it is needed because there are so many ways to write dates.

如果使用日期特定的JSF组件,则不必使用转换器.诸如Richfaces和Primefaces之类的组件库提供了日期组件,这些组件不需要转换器,并且可以直接验证用户输入.

You don't have to use a converter if you use a date specific JSF component. Component libraries like Richfaces and Primefaces offer date components which won't require a converter and will directly validate user input.

这篇关于JSF Converter f:convertDateTime如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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