Coverage Report - org.kuali.rice.kns.web.spring.UifConfigurableWebBindingInitializer
 
Classes in this File Line Coverage Branch Coverage Complexity
UifConfigurableWebBindingInitializer
0%
0/18
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 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  
  * Registers standard PropertyEditors used in binding for all http requests.
 30  
  * 
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
         // TODO do we need this since we are switching to spring tags
 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  
         // Use the spring custom number editor for Big decimals
 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  
         // Use the spring StringTrimmerEditor editor for Strings
 61  0
         binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
 62  
         // Use the StringArrayPropertyEditor for string arrays with "," as the
 63  
         // separator
 64  0
         binder.registerCustomEditor(String[].class, new StringArrayPropertyEditor(",", false));
 65  
 
 66  0
         super.initBinder(binder, request);
 67  0
     }
 68  
 
 69  
 }