Results 1 to 2 of 2

Thread: Validation errors on Command Object

  1. #1

    Default Validation errors on Command Object

    Hi,

    I have an optional field on my form that represents a money amount.

    I have declared the corresponding Command class to have a BigDecimal to hold this value.

    Spring parses it correctly when the value is given but throws an exception when it is not.

    Code:
    Error code: Failed to convert property value of type [java.lang.String] to required type [java.math.BigDecimal] for property 'maxAmount'; nested exception is java.lang.NumberFormatException: null
    How best to catch this and allow null for the BigDecimal?

    Thanks

    Rakesh

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Problem is that "null" translates to an empty string for html input text boxes.

    I suppose you could write your own property editor and register it on initBinder.

Similar Threads

  1. Replies: 46
    Last Post: Jan 19th, 2011, 01:15 PM
  2. Validation and displaying errors in jsp
    By jkookie in forum Web
    Replies: 3
    Last Post: Jun 5th, 2008, 03:28 PM
  3. Replies: 17
    Last Post: Jan 2nd, 2007, 01:43 PM
  4. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  5. ideas on displaying validation errors
    By lindbird in forum Web
    Replies: 1
    Last Post: Aug 26th, 2005, 01:03 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
  •