1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.web.bind;
17
18 import org.kuali.rice.core.api.util.RiceKeyConstants;
19 import org.kuali.rice.core.web.format.FormatException;
20 import org.kuali.rice.krad.util.GlobalVariables;
21 import org.springframework.beans.PropertyAccessException;
22 import org.springframework.validation.BindingResult;
23 import org.springframework.validation.DefaultBindingErrorProcessor;
24
25
26
27
28
29
30 public class UifBindingErrorProcessor extends DefaultBindingErrorProcessor {
31
32
33
34
35
36
37
38
39 @Override
40 public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
41
42 super.processPropertyAccessException(ex, bindingResult);
43
44 Object rejectedValue = ex.getValue();
45 if (!(rejectedValue == null || rejectedValue.equals(""))) {
46 if (ex.getCause() instanceof FormatException) {
47 GlobalVariables.getMessageMap().putError(ex.getPropertyName(),
48 ((FormatException) ex.getCause()).getErrorKey(),
49 new String[] {rejectedValue.toString()});
50 } else {
51 GlobalVariables.getMessageMap().putError(ex.getPropertyName(), RiceKeyConstants.ERROR_CUSTOM,
52 new String[] {"Invalid format"});
53 }
54 }
55 }
56 }