• Post Reply Bookmark Topic Watch Topic
  • New Topic

date converter  RSS feed

 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My last issue worked out well, so I figured I'd give another a try. Is this...

<f:convertDateTime dateStyle="short" />

expected to validate the input as well as format the output? I was under the impression that it would. Anytime I type in an invalid date, I get a stack trace:



Its in a dataTable element. Any thoughts?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the purpose of a converter is to create a string representation of an object for display purposes. I got this straight from JSF In Action page 252. Validators and Converters do two different things entirely.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread below might be helpful to build your understanding towards converters and validators.

http://www.coderanch.com/t/210818/JSF/java/Validation-before-conversion

Nevertheless, JSF In Action is a must.
[ August 12, 2005: Message edited by: Adeel Ansari ]
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both. I saw JSF in Action yesterday, but wasn't ready to drop a $50 bet. However, judging from my Hibernate in Action, it would probably be a safe bet.

Think I'll pick that up.

Not to knock the O'reilly book, but I think it again led me astray. From that book I gathered the converter would also validate...

Chapter 7: p. 120

The input component for the Date field is also declared as required and it is linked to an <h:message> action through a unique component ID. Additionally, a nested <f:convertDateTime> action configures the component with a DateTime converter. As described in the previous section, the converter ensures that the value the user enters is a syntactically correct date string. Otherwise, it adds an error message to the list, which the <h:message> action displays.


Emphasis added by yours truly.

Cheers.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!