Package org.springframework.format.support

Examples of org.springframework.format.support.FormattingConversionService$FieldFormatterKey


  public void testBindingErrorWithFormatterAgainstFields() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb);
    binder.initDirectFieldAccess();
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1x2");

    LocaleContextHolder.setLocale(Locale.GERMAN);
View Full Code Here


   * controller methods and the {@code spring:eval} JSP tag.
   * Also see {@link #addFormatters} as an alternative to overriding this method.
   */
  @Bean
  public FormattingConversionService mvcConversionService() {
    FormattingConversionService conversionService = new DefaultFormattingConversionService();
    addFormatters(conversionService);
    return conversionService;
  }
View Full Code Here

  }

  public void testBindingWithFormatter() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,2");

    LocaleContextHolder.setLocale(Locale.GERMAN);
View Full Code Here

  }

  public void testBindingErrorWithFormatter() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(Float.class, new NumberFormatter());
    binder.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1x2");

    LocaleContextHolder.setLocale(Locale.GERMAN);
View Full Code Here

  }

  public void testBindingErrorWithStringFormatter() {
    TestBean tb = new TestBean();
    DataBinder binder = new DataBinder(tb);
    FormattingConversionService conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);
    conversionService.addFormatterForFieldType(String.class, new Formatter<String>() {
      @Override
      public String parse(String text, Locale locale) throws ParseException {
        throw new ParseException(text, 0);
      }
      @Override
View Full Code Here

    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    setUp(registrar);
  }

  private void setUp(JodaTimeFormatterRegistrar registrar) {
    conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);

    registrar.registerFormatters(conversionService);

    JodaTimeBean bean = new JodaTimeBean();
View Full Code Here

  public void testWithMultiValueWithFormatter() throws Exception {
    this.tag.setPath("stringArray");
    this.tag.setItems(new Object[] {"   foo", "   bar", "   baz"});
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(this.bean, COMMAND_NAME);
    FormattingConversionService cs = new FormattingConversionService();
    cs.addFormatterForFieldType(String.class, new Formatter<String>() {
      @Override
      public String print(String object, Locale locale) {
        return object;
      }
      @Override
View Full Code Here

  public void testWithElementFormatter() throws Exception {
    this.bean.setRealCountry(Country.COUNTRY_UK);

    BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.bean, COMMAND_NAME);
    FormattingConversionService cs = new FormattingConversionService();
    cs.addFormatterForFieldType(Country.class, new Formatter<Country>() {
      @Override
      public String print(Country object, Locale locale) {
        return object.getName();
      }
      @Override
View Full Code Here

    list.add(Country.COUNTRY_UK);
    list.add(Country.COUNTRY_AT);
    this.bean.setSomeList(list);

    BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.bean, COMMAND_NAME);
    FormattingConversionService cs = new FormattingConversionService();
    cs.addFormatterForFieldType(Country.class, new Formatter<Country>() {
      @Override
      public String print(Country object, Locale locale) {
        return object.getName();
      }
      @Override
View Full Code Here

    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    setUp(registrar);
  }

  private void setUp(DateTimeFormatterRegistrar registrar) {
    conversionService = new FormattingConversionService();
    DefaultConversionService.addDefaultConverters(conversionService);

    registrar.registerFormatters(conversionService);

    DateTimeBean bean = new DateTimeBean();
View Full Code Here

TOP

Related Classes of org.springframework.format.support.FormattingConversionService$FieldFormatterKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.