Package org.springframework.web.bind

Examples of org.springframework.web.bind.WebDataBinder.bind()


    }

    private BindingResult bindAndValidate(HttpServletRequest request, Object formObject) {
        WebDataBinder binder = new WebDataBinder(formObject);
        binder.setValidator(validator);
        binder.bind(new MutablePropertyValues(request.getParameterMap()));
        binder.getValidator().validate(binder.getTarget(), binder.getBindingResult());
        return binder.getBindingResult();
    }

    private void initMessageSourceForFeedbackMessage(String feedbackMessageCode) {
View Full Code Here


     * @return  A binding result containing the outcome of binding and validation.
     */
    protected BindingResult bindAndValidate(HttpServletRequest request, Object formObject) {
        WebDataBinder binder = new WebDataBinder(formObject);
        binder.setValidator(validator);
        binder.bind(new MutablePropertyValues(request.getParameterMap()));
        binder.getValidator().validate(binder.getTarget(), binder.getBindingResult());
        return binder.getBindingResult();
    }

    /**
 
View Full Code Here

    WebDataBinder dataBinder = new WebDataBinder(target, "");
    dataBinder.setConversionService(new DefaultFormattingConversionService());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("testMap", source);
    dataBinder.bind(pvs);

    // FallbackObjectToStringConverter for key-value pairs
   
    assertSame(source.keySet().iterator().next(), target.getTestMap().keySet().iterator().next());
    assertSame(source.values().iterator().next(), target.getTestMap().values().iterator().next());
View Full Code Here

    WebDataBinder dataBinder = new WebDataBinder(target, "");
    dataBinder.setConversionService(new DefaultFormattingConversionService());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("testNumberMap", source);
    dataBinder.bind(pvs);

    // NumberToNumber converter for key-value pairs
   
    assertSame(source.keySet().iterator().next(), target.getTestNumberMap().keySet().iterator().next());
    assertSame(source.values().iterator().next(), target.getTestNumberMap().values().iterator().next());
View Full Code Here

    WebDataBinder dataBinder = new WebDataBinder(target, "");
    dataBinder.setConversionService(new DefaultFormattingConversionService());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("testIntegerMap", source);
    dataBinder.bind(pvs);

    // NumberToNumber converter for key-value pairs
   
    assertSame(source.keySet().iterator().next(), target.getTestIntegerMap().keySet().iterator().next());
    assertSame(source.values().iterator().next(), target.getTestIntegerMap().values().iterator().next());
View Full Code Here

    WebDataBinder dataBinder = new WebDataBinder(target, "");
    dataBinder.setConversionService(new DefaultFormattingConversionService());
   
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("testBeanMap", source);
    dataBinder.bind(pvs);

    // NO_OP converter for key-value pairs (no converter
   
    assertSame(source.keySet().iterator().next(), target.getTestBeanMap().keySet().iterator().next());
    assertSame(source.values().iterator().next(), target.getTestBeanMap().values().iterator().next());
View Full Code Here

                    WebDataBinder componentBinder = binderFactory.createBinder(request, component, null);
                    component = componentBinder.getTarget();

                    if (component != null) {
                        ServletRequestParameterPropertyValues pvs = new ServletRequestParameterPropertyValues(servletRequest, prefixName, "");
                        componentBinder.bind(pvs);
                        validateIfApplicable(componentBinder, parameter);
                        if (componentBinder.getBindingResult().hasErrors()) {
                            if (isBindExceptionRequired(componentBinder, parameter)) {
                                throw new BindException(componentBinder.getBindingResult());
                            }
View Full Code Here

                    WebDataBinder componentBinder = binderFactory.createBinder(request, component, null);
                    component = componentBinder.getTarget();

                    if (component != null) {
                        ServletRequestParameterPropertyValues pvs = new ServletRequestParameterPropertyValues(servletRequest, prefixName, "");
                        componentBinder.bind(pvs);

                        validateComponent(componentBinder, parameter);

                        target.put(keyValue, component);
                    }
View Full Code Here

  }

  @Test
  public void testVanillaBinding() throws Exception {
    WebDataBinder binder = new WebDataBinder(new TestBean(), "bean");
    binder.bind(new MutablePropertyValues(Collections.singletonMap("name", "foo")));
    TestBean bean = (TestBean) binder.getTarget();
    assertEquals("foo", bean.getName());
  }

  @Test
View Full Code Here

      public void setAsText(String text) throws IllegalArgumentException {
        setValue(text.replace("name_", ""));
      }
    });
    // This is all very well but not actually what we want
    binder.bind(new MutablePropertyValues(Collections.singletonMap("name", "name_foo")));
    TestBean bean = (TestBean) binder.getTarget();
    assertEquals("foo", bean.getName());
  }

  @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.