Results 1 to 3 of 3

Thread: Trapping bind errors to display as failed validation error

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    19

    Default Trapping bind errors to display as failed validation error

    Hi,

    I've successfully created validators to validate form input but I have one small issue: When a field that maps to a numeric field on command object is left blank or alfa data is entered, the following error is displayed:

    Code:
    Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property 'version'; nested exception is java.lang.NumberFormatException ...
    Where do I trap this exception and

    a) ignore it if the field is optional
    b) display a more user friendly message.

    Thanks very much. Regards,
    Stefan

  2. #2
    Join Date
    Apr 2005
    Posts
    19

    Default

    Sorry, I omitted some info to set the stage for the question:

    I have a subclass of SimpleFormController that uses formBackingObject to get the data to display,

    it has a validator that implements validate(Object command, Errors errors) to validate the user input and rejectValue(...) to set error messages for invalid user input

    and it uses onSubmit to save the user input.

    Regards,
    Stefan

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    a) I don't think you can 'ignore' the error, if the user enters data for the field, the binder will try to bind it and you will get some error if that fails.

    b) Check the JavaDoc for DataBinder, DefaultMessageCodesResolver and MessageTag.

    BTW: SimpleFormController related questions should go in the "Web" forum, since they do not relate to Spring Web Flow.

    Erwin

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. Replies: 2
    Last Post: Apr 29th, 2005, 03:43 AM
  3. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  4. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  5. Replies: 4
    Last Post: Nov 5th, 2004, 03:59 AM

Posting Permissions

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