• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date converter

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thread below might be helpful to build your understanding towards converters and validators.

https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic