简体   繁体   中英

How the JSF Converter f:convertDateTime works?

I have a question concerning the JSF Converter

f:convertDateTime

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>

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

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 ?

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?

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. Component libraries like Richfaces and Primefaces offer date components which won't require a converter and will directly validate user input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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