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