Announcement Announcement Module
Collapse
No announcement yet.
Trapping bind errors to display as failed validation error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    You need to add something like:
    Code:
    binder.registerCustomEditor(Integer.class, "myNumericProperty", new CustomNumberEditor(Integer.class, true));
    The true is to allow empty entries.

    NB. You'll still get validation error messages if you enter alpha characters - this is correct behaviour.

    Comment


    • #3
      Thanks Katentim,

      I've just checked the docs and both the built-in CustomNumberEditor and CustomDateEditor have a parameter to allow empty fields! Lovely

      Regards,
      Stefan

      Comment

      Working...
      X