Results 1 to 3 of 3

Thread: NumberFormatException binding to Number

  1. #1
    Join Date
    Aug 2004
    Location
    New York
    Posts
    168

    Default NumberFormatException binding to Number

    We are binding a text input field to a property of type Long on our command class. We have a Validator which checks that the user's input is a valid number format, but in the case the user enters non-digit characters, these validations are never reached. Instead, the CustomNumberEditor throws a NumberFormatException and the user gets the following error message in the jsp:

    Code:
    Failed to convert property value of type [java.lang.String] to required type [java.lang.Long] for property 'quantity'; nested exception is java.lang.NumberFormatException: For input string: "dfkjd"
    Is there any way to customize this error message? Thanks.

    -karl

  2. #2
    Join Date
    Aug 2004
    Posts
    29

    Default

    Yes there is, and you can do a lot with it.

    e.g.
    typeMismatch.java.sql.Date=Could not convert date

    see http://www.springframework.org/docs/...sResolver.html

    or search this forum a bit

  3. #3
    Join Date
    Aug 2004
    Location
    New York
    Posts
    168

    Default

    This is a great help. Thx!

Similar Threads

  1. Enum binding not showing default
    By ge0ffrey in forum Swing
    Replies: 3
    Last Post: Jan 23rd, 2006, 09:08 AM
  2. Replies: 7
    Last Post: Sep 13th, 2005, 01:45 AM
  3. Stop validation if binding fails.
    By sherihan in forum Web
    Replies: 0
    Last Post: Feb 8th, 2005, 03:18 AM
  4. Replies: 0
    Last Post: Jan 6th, 2005, 08:19 AM
  5. Replies: 2
    Last Post: Aug 17th, 2004, 04:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •