I've noticed that my custom validator is ignored on form input fields which accept numeric values. Instead of displaying my custom error message, the form shows a NumberFormatException.
We've traced this behavior back to the CustomNumberEditor, and realized that the editor automatically attempts to convert the input string to the desired numeric value, and sets the error in the process when, for example, the value is null.
We've devised a work around by explicitly registering the CustomNumberEditor in the controller:
This sets the "allowEmpty" property of the controller to true, and allows my custom validator to do it's thing.
binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true));
For some reason, this seems to be a bit of a hack rather than the intended behavior/use of the CustomNumberEditor and a custom validator.
Is this the accepted way of handling this situation? or is there some other way you do this?