Announcement Announcement Module
Collapse
No announcement yet.
Trapping parse errors in the validator? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trapping parse errors in the validator?

    I have a CustomDateEditor registered via initBinder(), but what I can't work out (although I'm sure it must be obvious and I'm just having a stupidity day) is how, within my validator, I trap any exceptions the CustomDateEditor might throw in its attempts to parse the input. For example, when I submit a form containing an invalid date, this is what ends up in my errors object for display on the form the user ends back at:

    'Failed to convert property value of type [java.lang.String] to required type [java.sql.Date] for property 'betDate'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: "29/01/tt"'

    Obviously what I want is to trap this error and display a more useful message but I must have missed how I do this.

  • #2
    You can create messages for the conversion exceptions such as:

    typeMismatch.java.util.Date={0} must be a date.


    There's some good discussion on this here: http://forum.springframework.org/sho...java.util.Date

    Also, the javadocs...
    http://www.springframework.org/docs/...sResolver.html

    http://www.springframework.org/docs/...ataBinder.html

    cheers,
    rob

    Comment


    • #3
      Great, that answers my question nicely! Thanks.

      Comment

      Working...
      X