简体   繁体   English

JSF Converter f:convertDateTime如何工作?

[英]How the JSF Converter f:convertDateTime works?

I have a question concerning the JSF Converter 我有一个关于JSF Converter的问题

f:convertDateTime

I i use this converter in this context (bean.date represent the Java class java.util.Date ): 我在此上下文中使用此转换器(bean.date表示Java类java.util.Date ):

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

Works this converter only to format xhtml page for the user in the response from the webserver? 该转换器只能在Web服务器的响应中为用户格式化xhtml页面的格式吗?

Or will the entered value formatted with the pattern dM-yyyy , if the request was send to the webserver and stored in the backing bean with the pattern format dM-yyyy ? 或者,如果请求已发送到Web服务器并以dM-yyyy格式存储在支持bean中,则输入的值是否将以dM-yyyy格式设置?

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? 是否可以在不使用任何f:convertDateTime的情况下将xhtml页面中的某些Date值插入到后备bean中,还是绝对必要?

Greetz Marwief 格蕾兹·马维夫(Greetz Marwief)

The converter is used for conversions both ways and it is needed because there are so many ways to write dates. 该转换器用于两种方式的转换,这是必需的,因为有很多写入日期的方式。

You don't have to use a converter if you use a date specific JSF component. 如果使用日期特定的JSF组件,则不必使用转换器。 Component libraries like Richfaces and Primefaces offer date components which won't require a converter and will directly validate user input. 诸如Richfaces和Primefaces之类的组件库提供了日期组件,这些组件不需要转换器,并且可以直接验证用户输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM