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.type.AbstractKualiDecimal;
19 import org.kuali.rice.core.api.util.type.KualiDecimal;
20 import org.kuali.rice.core.api.util.type.KualiInteger;
21 import org.kuali.rice.core.api.util.type.KualiPercent;
22 import org.springframework.beans.propertyeditors.CustomNumberEditor;
23 import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
24 import org.springframework.beans.propertyeditors.StringTrimmerEditor;
25 import org.springframework.web.bind.WebDataBinder;
26 import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
27 import org.springframework.web.context.request.WebRequest;
28
29 import java.math.BigDecimal;
30 import java.sql.Timestamp;
31 import java.text.DecimalFormat;
32
33
34
35
36
37
38 public class UifConfigurableWebBindingInitializer extends ConfigurableWebBindingInitializer {
39
40 @Override
41 public void initBinder(WebDataBinder binder, WebRequest request) {
42 super.initBinder(binder, request);
43
44 binder.registerCustomEditor(KualiDecimal.class, new UifCurrencyEditor());
45 binder.registerCustomEditor(KualiInteger.class, new UifKualiIntegerCurrencyEditor());
46
47 binder.registerCustomEditor(KualiPercent.class, new UifPercentageEditor());
48
49 binder.registerCustomEditor(java.sql.Date.class, new UifDateEditor());
50 binder.registerCustomEditor(java.util.Date.class, new UifDateEditor());
51 binder.registerCustomEditor(Timestamp.class, new UifTimestampEditor());
52
53
54 binder.registerCustomEditor(boolean.class, new UifBooleanEditor());
55 binder.registerCustomEditor(Boolean.class, new UifBooleanEditor());
56 binder.registerCustomEditor(Boolean.TYPE, new UifBooleanEditor());
57
58
59 DecimalFormat bigIntFormatter = new DecimalFormat();
60 bigIntFormatter.setMaximumFractionDigits(340);
61 binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, bigIntFormatter, true));
62 binder.registerCustomEditor(AbstractKualiDecimal.class,
63 new CustomNumberEditor(AbstractKualiDecimal.class, bigIntFormatter, true));
64
65
66 binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
67
68
69 binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(",", false));
70 }
71 }