Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
UifBindingErrorProcessor |
|
| 4.0;4 |
1 | /** | |
2 | * Copyright 2005-2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
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 | * This is a description of what this class does - pctsh don't forget to fill this in. | |
27 | * | |
28 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
29 | * | |
30 | */ | |
31 | 0 | public class UifBindingErrorProcessor extends DefaultBindingErrorProcessor { |
32 | ||
33 | public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult) { | |
34 | // Create field error with the exceptions's code, e.g. "typeMismatch". | |
35 | 0 | super.processPropertyAccessException(ex, bindingResult); |
36 | 0 | Object rejectedValue = ex.getValue(); |
37 | 0 | if (!(rejectedValue == null || rejectedValue.equals(""))) { |
38 | 0 | if (ex.getCause() instanceof FormatException) { |
39 | 0 | GlobalVariables.getMessageMap().putError(ex.getPropertyName(), ((FormatException)ex.getCause()).getErrorKey(), |
40 | new String[] {rejectedValue.toString()}); | |
41 | }else{ | |
42 | 0 | GlobalVariables.getMessageMap().putError(ex.getPropertyName(), RiceKeyConstants.ERROR_CUSTOM, |
43 | new String[] {"Invalid format"}); | |
44 | } | |
45 | } | |
46 | 0 | } |
47 | ||
48 | } |