org.springframework.beans.propertyeditors.CustomNumberEditor Java Examples

The following examples show how to use org.springframework.beans.propertyeditors.CustomNumberEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrailsDataBinder.java    From AlgoTrader with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers all known
 *
 * @param registry
 * @param locale
 */
public static void registerCustomEditors(PropertyEditorRegistry registry, Locale locale) {
	// Formatters for the different number types.
	NumberFormat floatFormat = NumberFormat.getInstance(locale);
	NumberFormat integerFormat = NumberFormat.getIntegerInstance(locale);

	DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT, locale);

	registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	registry.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, floatFormat, true));
	registry.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, floatFormat, true));
	registry.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, floatFormat, true));
	registry.registerCustomEditor(double.class, new CustomNumberEditor(Double.class, floatFormat, true));
	registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, floatFormat, true));
	registry.registerCustomEditor(float.class, new CustomNumberEditor(Float.class, floatFormat, true));
	registry.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, integerFormat, true));
	registry.registerCustomEditor(long.class, new CustomNumberEditor(Long.class, integerFormat, true));
	registry.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, integerFormat, true));
	registry.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, integerFormat, true));
	registry.registerCustomEditor(Short.class, new CustomNumberEditor(Short.class, integerFormat, true));
	registry.registerCustomEditor(short.class, new CustomNumberEditor(Short.class, integerFormat, true));
	registry.registerCustomEditor(Date.class, new StructuredDateEditor(dateFormat, true));
	registry.registerCustomEditor(Calendar.class, new StructuredDateEditor(dateFormat, true));

	registerCustomEditors(registry);
}
 
Example #2
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testCustomEditor() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", "1,1");
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #3
Source File: DefaultListableBeanFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testCustomEditorWithBeanReference() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	lbf.registerSingleton("myFloat", "1,1");
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #4
Source File: BeanWrapperGenericsTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testGenericMapWithCollectionValue() {
	GenericBean<?> gb = new GenericBean<>();
	BeanWrapper bw = new BeanWrapperImpl(gb);
	bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
	Map<String, Collection> input = new HashMap<>();
	HashSet<Integer> value1 = new HashSet<>();
	value1.add(new Integer(1));
	input.put("1", value1);
	ArrayList<Boolean> value2 = new ArrayList<>();
	value2.add(Boolean.TRUE);
	input.put("2", value2);
	bw.setPropertyValue("collectionMap", input);
	assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet);
	assertTrue(gb.getCollectionMap().get(new Integer(2)) instanceof ArrayList);
}
 
Example #5
Source File: BaseController.java    From ankush with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Set up a custom property editor for converting form inputs to real
 * objects.
 *
 * @param request the current request
 * @param binder the data binder
 */
@InitBinder
protected void initBinder(HttpServletRequest request,
		ServletRequestDataBinder binder) {
	binder.registerCustomEditor(Integer.class, null,
			new CustomNumberEditor(Integer.class, null, true));
	binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(
			Long.class, null, true));
	binder.registerCustomEditor(byte[].class,
			new ByteArrayMultipartFileEditor());
	SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy.MM.dd G 'at' HH:mm:ss z");
	dateFormat.setLenient(false);
	binder.registerCustomEditor(Date.class, null, new CustomDateEditor(
			dateFormat, true));
}
 
Example #6
Source File: EditScheduleController.java    From webcurator with Apache License 2.0 6 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Integer.class, "scheduleType", new CustomNumberEditor(Integer.class, nf, true));
      binder.registerCustomEditor(java.util.Date.class, org.webcurator.ui.util.DateUtils.get().getFullDateEditor(true));
      binder.registerCustomEditor(Time.class, new TimeEditor(false));
  }
 
Example #7
Source File: BeanWrapperGenericsTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testGenericMapWithCollectionValue() {
	GenericBean<?> gb = new GenericBean<>();
	BeanWrapper bw = new BeanWrapperImpl(gb);
	bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
	Map<String, Collection> input = new HashMap<>();
	HashSet<Integer> value1 = new HashSet<>();
	value1.add(new Integer(1));
	input.put("1", value1);
	ArrayList<Boolean> value2 = new ArrayList<>();
	value2.add(Boolean.TRUE);
	input.put("2", value2);
	bw.setPropertyValue("collectionMap", input);
	assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet);
	assertTrue(gb.getCollectionMap().get(new Integer(2)) instanceof ArrayList);
}
 
Example #8
Source File: DefaultListableBeanFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testCustomEditor() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", "1,1");
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #9
Source File: DefaultListableBeanFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testCustomEditorWithBeanReference() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	lbf.registerSingleton("myFloat", "1,1");
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #10
Source File: BeanWrapperGenericsTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testGenericMapWithCollectionValue() {
	GenericBean<?> gb = new GenericBean<Object>();
	BeanWrapper bw = new BeanWrapperImpl(gb);
	bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
	Map<String, Collection> input = new HashMap<String, Collection>();
	HashSet<Integer> value1 = new HashSet<Integer>();
	value1.add(new Integer(1));
	input.put("1", value1);
	ArrayList<Boolean> value2 = new ArrayList<Boolean>();
	value2.add(Boolean.TRUE);
	input.put("2", value2);
	bw.setPropertyValue("collectionMap", input);
	assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet);
	assertTrue(gb.getCollectionMap().get(new Integer(2)) instanceof ArrayList);
}
 
Example #11
Source File: SitePermissionController.java    From webcurator with Apache License 2.0 6 votes vote down vote up
/**
 * Initialise some special binders for this command. (Overrides Spring
 * method).
 * @param request The HttpServletRequest.
 * @param binder  The binder.
 */
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);
	
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());	
       
       // Register the binders.
       binder.registerCustomEditor(Long.class, "selectedPermission", new CustomNumberEditor(Long.class, nf, true));
	binder.registerCustomEditor(java.util.Date.class, "startDate", DateUtils.get().getFullDateEditor(true));
	binder.registerCustomEditor(java.util.Date.class, "endDate", DateUtils.get().getFullDateEditor(true));
	binder.registerCustomEditor(java.util.Date.class, "openAccessDate", DateUtils.get().getFullDateEditor(true));
	
	// If the session model is available, we want to register the Permission's
	// authorising agency editor.
	if(getEditorContext(request) != null) {
		binder.registerCustomEditor(AuthorisingAgent.class, "authorisingAgent", new EditorContextObjectEditor(getEditorContext(request), AuthorisingAgent.class));
		binder.registerCustomEditor(Set.class, "urls", new UrlPatternCollectionEditor(Set.class, true, getEditorContext(request)));
		binder.registerCustomEditor(Integer.class, "deleteExclusionIndex", new CustomNumberEditor(Integer.class, true));
	}
}
 
Example #12
Source File: SitePermissionHandler.java    From webcurator with Apache License 2.0 6 votes vote down vote up
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);
	
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());	
       
       // Register the binders.
       binder.registerCustomEditor(Long.class, "selectedPermission", new CustomNumberEditor(Long.class, nf, true));
	binder.registerCustomEditor(java.util.Date.class, "startDate", DateUtils.get().getFullDateEditor(true));
	binder.registerCustomEditor(java.util.Date.class, "endDate", DateUtils.get().getFullDateEditor(true));
	
	// If the session model is available, we want to register the Permission's
	// authorising agency editor.
	if(getEditorContext(request) != null) {
		//binder.registerCustomEditor(AuthorisingAgent.class, new PermissionAuthAgencyEditor(sessionModel.getAuthorisingAgents()));
		binder.registerCustomEditor(AuthorisingAgent.class, "authorisingAgent", new EditorContextObjectEditor(getEditorContext(request), AuthorisingAgent.class));
		binder.registerCustomEditor(Set.class, "urls", new UrlPatternCollectionEditor(Set.class, true, getEditorContext(request)));
	}
}
 
Example #13
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomEditor() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", "1,1");
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #14
Source File: DefaultListableBeanFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomEditorWithBeanReference() {
	DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
	lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
		@Override
		public void registerCustomEditors(PropertyEditorRegistry registry) {
			NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
			registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
	RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
	bd.setPropertyValues(pvs);
	lbf.registerBeanDefinition("testBean", bd);
	lbf.registerSingleton("myFloat", "1,1");
	TestBean testBean = (TestBean) lbf.getBean("testBean");
	assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
 
Example #15
Source File: TargetSearchController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	// TODO Auto-generated method stub
	super.initBinder(request, binder);
	binder.registerCustomEditor(Set.class, "states", new CustomIntegerCollectionEditor(Set.class,true));
	binder.registerCustomEditor(Long.class, "selectedTargetOid", new CustomNumberEditor(Long.class,true));
	binder.registerCustomEditor(Long.class, "searchOid", new CustomNumberEditor(Long.class,true));
}
 
Example #16
Source File: TargetGroupsHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.webcurator.ui.util.TabHandler#initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
 */
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);

	// Register a number binder.
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
}
 
Example #17
Source File: TargetSchedulesHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Integer.class, "scheduleType", new CustomNumberEditor(Integer.class, nf, true));
      binder.registerCustomEditor(java.util.Date.class, org.webcurator.ui.util.DateUtils.get().getFullDateEditor(true));       
  }
 
Example #18
Source File: AbstractOverrideTabHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, nf, true));
  }
 
Example #19
Source File: ProfileController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);

	// Ensure that the Profile Oid parameter can be null (for create).
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, "profileOid", new CustomNumberEditor(Long.class, nf, true));
}
 
Example #20
Source File: QaIndicatorReportController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
protected void initBinder(HttpServletRequest request,
		ServletRequestDataBinder binder) {
	// enable null values for long and float fields
	NumberFormat nf = NumberFormat.getInstance(request.getLocale());
	NumberFormat floatFormat = new DecimalFormat("##############.##");
	binder.registerCustomEditor(java.lang.Long.class,
			new CustomNumberEditor(java.lang.Long.class, nf, true));
	binder.registerCustomEditor(java.lang.Float.class,
			new CustomNumberEditor(java.lang.Float.class, nf, true));
}
 
Example #21
Source File: CreateFlagController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	// enable null values for long and float fields
    NumberFormat nf = NumberFormat.getInstance(request.getLocale());
    binder.registerCustomEditor(java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, nf, true));   
    binder.registerCustomEditor(java.lang.Float.class, new CustomNumberEditor(java.lang.Float.class, nf, true));   
}
 
Example #22
Source File: TargetInstanceAnnotationHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    NumberFormat nf = NumberFormat.getInstance(request.getLocale());        
    binder.registerCustomEditor(java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, nf, true));
    binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, nf, true));
    binder.registerCustomEditor(java.util.Date.class, DateUtils.get().getFullDateTimeEditor(true));
  
}
 
Example #23
Source File: TabbedTargetController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);
	
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, "targetOid", new CustomNumberEditor(Long.class, nf, true));
}
 
Example #24
Source File: TargetSeedsHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      
      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
 
Example #25
Source File: SiteController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);
	
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, "siteOid", new CustomNumberEditor(Long.class, nf, true));
}
 
Example #26
Source File: TreeToolController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
  public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
// Determine the necessary formats.
      NumberFormat nf = NumberFormat.getInstance(request.getLocale());
      
      // Register the binders.
      binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
      binder.registerCustomEditor(Boolean.class, "propagateDelete", new CustomBooleanEditor(true));
      
      // to actually be able to convert Multipart instance to byte[]
      // we have to register a custom editor (in this case the
      // ByteArrayMultipartEditor
      binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
      // now Spring knows how to handle multipart object and convert them
  }
 
Example #27
Source File: DataBinderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testBindingWithCustomEditorOnObjectField() {
	BeanWithObjectProperty tb = new BeanWithObjectProperty();
	DataBinder binder = new DataBinder(tb);
	binder.registerCustomEditor(Integer.class, "object", new CustomNumberEditor(Integer.class, true));
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("object", "1");
	binder.bind(pvs);
	assertEquals(new Integer(1), tb.getObject());
}
 
Example #28
Source File: MembersHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.webcurator.ui.util.TabHandler#initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
 */
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);

	// Register a number binder.
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
}
 
Example #29
Source File: MemberOfHandler.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.webcurator.ui.util.TabHandler#initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
 */
@Override
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);

	// Register a number binder.
       NumberFormat nf = NumberFormat.getInstance(request.getLocale());
       binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, nf, true));
}
 
Example #30
Source File: QaIndicatorController.java    From webcurator with Apache License 2.0 5 votes vote down vote up
@Override
 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) {
 	// enable null values for long and float fields
     NumberFormat nf = NumberFormat.getInstance(request.getLocale());
     NumberFormat floatFormat = new DecimalFormat("##############.##");
     binder.registerCustomEditor(java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, nf, true));   
     binder.registerCustomEditor(java.lang.Float.class, new CustomNumberEditor(java.lang.Float.class, nf, true));   
}