|
From: Ben A. <ben...@ac...> - 2004-10-04 22:13:53
|
Ben Alex wrote:
> My controller then does this:
>
> protected void onBindAndValidate(HttpServletRequest request,
> Object command, BindException errors) throws Exception {
> Person person = (Person) command;
> if (errors.hasFieldErrors("luhn")) {
> // Cast is safe as createBinder caused MyBindException to
> be used
> MyBindException myErrors = (MyBindException) errors;
> errors.rejectValue("luhn", "LUHN_INVALID", "A valid Luhn is
> required.");
> } ....
>
>
Ooops, that code fragment forgot a line:
// Cast is safe as createBinder caused MyBindException to be use
MyBindException myErrors = (MyBindException) errors;
myErrors.removeErrors(myErrors.getFieldErrors("luhn"));
// *********
errors.rejectValue("luhn", "LUHN_INVALID", "2 A valid Luhn is
required.");
|