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
31 public class UifBindingErrorProcessor extends DefaultBindingErrorProcessor {
32
33 public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) {
34
35 super.processPropertyAccessException(ex, bindingResult);
36 Object rejectedValue = ex.getValue();
37 if (!(rejectedValue == null || rejectedValue.equals(""))) {
38 if (ex.getCause() instanceof FormatException) {
39 GlobalVariables.getMessageMap().putError(ex.getPropertyName(), ((FormatException)ex.getCause()).getErrorKey(),
40 new String[] {rejectedValue.toString()});
41 }else{
42 GlobalVariables.getMessageMap().putError(ex.getPropertyName(), RiceKeyConstants.ERROR_CUSTOM,
43 new String[] {"Invalid format"});
44 }
45 }
46 }
47
48 }