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