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 | 0 | public class UifConfigurableWebBindingInitializer extends ConfigurableWebBindingInitializer { |
34 | |
|
35 | |
@Override |
36 | |
public void initBinder(WebDataBinder binder, WebRequest request) { |
37 | 0 | binder.registerCustomEditor(KualiDecimal.class, new UifCurrencyEditor()); |
38 | 0 | binder.registerCustomEditor(KualiInteger.class, new UifKualiIntegerCurrencyEditor()); |
39 | |
|
40 | 0 | binder.registerCustomEditor(KualiPercent.class, new UifPercentageEditor()); |
41 | |
|
42 | 0 | binder.registerCustomEditor(java.sql.Date.class, new UifDateEditor()); |
43 | 0 | binder.registerCustomEditor(java.util.Date.class, new UifDateEditor()); |
44 | 0 | binder.registerCustomEditor(Timestamp.class, new UifTimestampEditor()); |
45 | |
|
46 | |
|
47 | 0 | binder.registerCustomEditor(boolean.class, new UifBooleanEditor()); |
48 | 0 | binder.registerCustomEditor(Boolean.class, new UifBooleanEditor()); |
49 | 0 | binder.registerCustomEditor(Boolean.TYPE, new UifBooleanEditor()); |
50 | |
|
51 | |
|
52 | 0 | DecimalFormat bigIntFormatter = new DecimalFormat(); |
53 | 0 | bigIntFormatter.setMaximumFractionDigits(340); |
54 | 0 | binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, bigIntFormatter, true)); |
55 | 0 | binder.registerCustomEditor(AbstractKualiDecimal.class, |
56 | |
new CustomNumberEditor(AbstractKualiDecimal.class, bigIntFormatter, true)); |
57 | |
|
58 | |
|
59 | 0 | binder.registerCustomEditor(String.class, new StringTrimmerEditor(false)); |
60 | |
|
61 | |
|
62 | 0 | binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(",", false)); |
63 | |
|
64 | 0 | super.initBinder(binder, request); |
65 | 0 | } |
66 | |
} |