1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.kuali.rice.kns.web.spring; |
12 | |
|
13 | |
import java.math.BigDecimal; |
14 | |
import java.sql.Timestamp; |
15 | |
import java.text.DecimalFormat; |
16 | |
|
17 | |
import org.kuali.rice.core.util.type.AbstractKualiDecimal; |
18 | |
import org.kuali.rice.core.util.type.KualiDecimal; |
19 | |
import org.kuali.rice.core.util.type.KualiInteger; |
20 | |
import org.kuali.rice.core.util.type.KualiPercent; |
21 | |
import org.springframework.beans.propertyeditors.CustomNumberEditor; |
22 | |
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; |
23 | |
import org.springframework.beans.propertyeditors.StringTrimmerEditor; |
24 | |
import org.springframework.web.bind.WebDataBinder; |
25 | |
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; |
26 | |
import org.springframework.web.context.request.WebRequest; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class UifConfigurableWebBindingInitializer extends ConfigurableWebBindingInitializer { |
34 | |
|
35 | |
@Override |
36 | |
public void initBinder(WebDataBinder binder, WebRequest request) { |
37 | |
|
38 | |
|
39 | 0 | binder.registerCustomEditor(KualiDecimal.class, new UifCurrencyEditor()); |
40 | 0 | binder.registerCustomEditor(KualiInteger.class, new UifKualiIntegerCurrencyEditor()); |
41 | |
|
42 | 0 | binder.registerCustomEditor(KualiPercent.class, new UifPercentageEditor()); |
43 | |
|
44 | 0 | binder.registerCustomEditor(java.sql.Date.class, new UifDateEditor()); |
45 | 0 | binder.registerCustomEditor(java.util.Date.class, new UifDateEditor()); |
46 | 0 | binder.registerCustomEditor(Timestamp.class, new UifDateViewTimestampEditor()); |
47 | |
|
48 | |
|
49 | 0 | binder.registerCustomEditor(boolean.class, new UifBooleanEditor()); |
50 | 0 | binder.registerCustomEditor(Boolean.class, new UifBooleanEditor()); |
51 | 0 | binder.registerCustomEditor(Boolean.TYPE, new UifBooleanEditor()); |
52 | |
|
53 | |
|
54 | 0 | DecimalFormat bigIntFormatter = new DecimalFormat(); |
55 | 0 | bigIntFormatter.setMaximumFractionDigits(340); |
56 | 0 | binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, bigIntFormatter, true)); |
57 | 0 | binder.registerCustomEditor(AbstractKualiDecimal.class, new CustomNumberEditor(AbstractKualiDecimal.class, |
58 | |
bigIntFormatter, true)); |
59 | |
|
60 | |
|
61 | 0 | binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); |
62 | |
|
63 | |
|
64 | 0 | binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(",", false)); |
65 | |
|
66 | 0 | super.initBinder(binder, request); |
67 | 0 | } |
68 | |
|
69 | |
} |