Announcement Announcement Module
Collapse
No announcement yet.
SimpleFormController and binding errors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleFormController and binding errors

    Hi all,

    I have a problem with the binding error message.

    I use a SimpleFormController. In the form, user can do actions which require no validations (isFormChangeRequest to determine it). When he valids, this works fine. When he changes the form, it's ok, except that binding error message appears...

    Binding is done before validation, so if a user change the form with wrong datas in fields, he gets an error message.

    Exemple :
    - Type 'test' in a field bind with a CustomDateEditor
    - Click on change form button
    - Page reload (no validation)
    - The error message for an invalid date appears.... not wanted because no validations has been done.

    I don't want to show this message, because it's not a validation.

    How can i do to remove these error messages in a proper way ?
    Can i ignore them ?

    Thx

    PS : sorry for my bad english i'm not an english speaking

  • #2
    Type 'test' in a field bind with a CustomDateEditor...The error message for an invalid date appears....not wanted because no validations has been done
    This is the way Spring works. Validation on a date is meaningless if the input cannot be converted to an actual date.

    Comment


    • #3
      I feel this is all too easy. The problem has been raised a couple of times before with the same answer each time. An invalid date is to me also a kind of validation error (typically wrong format). I do understand that the command object cannot be completely created out of the data of the form when binding errors occur, but that doesn't matter much.

      Even worse, if you want to remove the command object from the session (with session form = true) and then redirect to another page, the user MUST correct the date even if you (and especially the user) don't care.

      Cheers, Stefaan.

      Comment


      • #4
        The problem has been raised a couple of times before with the same answer each time.
        This isn't a problem. Spring behaves as expected. What would you expect to happen if an invalid date is entered?

        An invalid date is to me also a kind of validation error (typically wrong format).
        Which is why Spring raises the exception for you.

        Even worse, if you want to remove the command object from the session (with session form = true) and then redirect to another page, the user MUST correct the date even if you (and especially the user) don't care.
        You can always allow the user to click on another link and remove the object from the session manually.

        Comment


        • #5
          Originally posted by katentim
          The problem has been raised a couple of times before with the same answer each time.
          This isn't a problem. Spring behaves as expected. What would you expect to happen if an invalid date is entered?
          Well, I would expect the same possibilities as validation, so a supressBinding() for example next to a supressValidation().

          Originally posted by katentim
          An invalid date is to me also a kind of validation error (typically wrong format).
          Which is why Spring raises the exception for you.
          Yes, but that's different from validation which you can turn off. If there is a binding error, Spring won't go into the onSubmit() method.

          Originally posted by katentim
          Even worse, if you want to remove the command object from the session (with session form = true) and then redirect to another page, the user MUST correct the date even if you (and especially the user) don't care.
          You can always allow the user to click on another link and remove the object from the session manually.
          Unfortunatly that is not that easy, especially if you want to allow the user to have multiple windows open (in firefox this doesn't cause a new session). Going through the same controller avoids this problem, but it would be convenient to turn off binding as you would turn off validation.

          This would make solutions as discussed in for example the thread http://forum.springframework.org/viewtopic.php?t=4713 more correct !

          Comment

          Working...
          X