I have some questions for the MyFaces folks about their thinking
concerning converters and validators.

I'm reading a JSF book now that makes the argument that its perfectly
acceptable to perform validation in your converter.  I think the
author makes a good case and I can envision scenarios where this is
actually necessary.

I have one scenario in mind that has come up with our Struts project. 
In Struts we have a converter that converts String to Date using the
SimpleDateFormat::parseDate method.  That's fine except if the user
types in a date that doesn't make sense like '02/31/2005'. 
Unfortunately Java just decides to convert it into a Date the best way
it can (without throwing an exception.)

I was thinking that in this case, I would check for valid month, etc.
in my converter and throw a conversion exception if its invalid. 
Otherwise its too late when you get to the validation phase because
the date is now valid (just not what the user entered!).

Anyone have any thoughts on this (or the general strategy of where to
put validation logic?)

TIA,

sean

Reply via email to