Announcement Announcement Module
Collapse
No announcement yet.
petclinic experts: How does the BindException gets resolved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • petclinic experts: How does the BindException gets resolved

    In the petclinic example, if I try to add a pet I am asked to provide the birthdate of the pet. If I submit an empty date field I get an appropriate message: 'invalid date'.

    Since the date field is invalid a bind exception is thrown and the model with the error is sent for presentation. If your message resource is not properly configures you'll get following message.
    Code:
    Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'birthDate'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: ""
    The message we get is
    invalid date
    .

    The magic is done in the message resource file with the following line
    Code:
    typeMismatch.birthDate=invalid date
    My question is what type of exceptions are given the key word *typeMismatch* and where could I find the complete list of such key exception-transalor words.

    Thanks.
    - Simon

  • #2
    My question is what type of exceptions are given the key word *typeMismatch*
    Only org.springframework.beans.TypeMismatchException, which is thrown if (of course) the type supplied cannot be converted by the relevant PropertyEditor.

    where could I find the complete list of such key exception-transalor words.
    Generally TypeMismatchException is the only one you need to report data entry problems to end users (and thus need a property file for). Other exceptions are generally programming errors, which you would never want to occur or be reported to the end user.

    AFAIK, the complete list can be found by searching for classes implementing the interface ErrorCoded which is only:
    org.springframework.beans.MethodInvocationExceptio n (methodInvocation)

    Comment

    Working...
    X