user2504767
user2504767

Reputation:

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 d-M-yyyy, if the request was send to the webserver and stored in the backing bean with the pattern format d-M-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

Upvotes: 1

Views: 717

Answers (1)

Eelke
Eelke

Reputation: 21993

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.

Upvotes: 1

Related Questions