Package org.springframework.web.bind

Examples of org.springframework.web.bind.WebDataBinder


      else if (required) {
        raiseMissingCookieException(cookieName, paramType);
      }
      cookieValue = checkValue(cookieName, cookieValue, paramType);
    }
    WebDataBinder binder = createBinder(webRequest, null, cookieName);
    initBinder(handlerForInitBinderCall, cookieName, binder, webRequest);
    return binder.convertIfNecessary(cookieValue, paramType, methodParam);
  }
View Full Code Here


    Class<?> paramType = methodParam.getParameterType();
    if (pathVarName.length() == 0) {
      pathVarName = getRequiredParameterName(methodParam);
    }
    String pathVarValue = resolvePathVariable(pathVarName, paramType, webRequest);
    WebDataBinder binder = createBinder(webRequest, null, pathVarName);
    initBinder(handlerForInitBinderCall, pathVarName, binder, webRequest);
    return binder.convertIfNecessary(pathVarValue, paramType, methodParam);
  }
View Full Code Here

      }
    }
    else {
      bindObject = BeanUtils.instantiateClass(paramType);
    }
    WebDataBinder binder = createBinder(webRequest, bindObject, name);
    initBinder(handler, name, binder, webRequest);
    return binder;
  }
View Full Code Here

    @Override
    public WebDataBinder createBinder(NativeWebRequest webRequest, Object target, String objectName) throws Exception {
      LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
      validator.afterPropertiesSet();
      WebDataBinder dataBinder = new WebDataBinder(target, objectName);
      dataBinder.setValidator(validator);
      return dataBinder;
    }
View Full Code Here

  private NativeWebRequest webRequest;

  @Before
  public void setUp() throws Exception {
    paramErrors = new MethodParameter(getClass().getDeclaredMethod("handle", Errors.class), 0);
    bindingResult = new WebDataBinder(new Object(), "attr").getBindingResult();
    webRequest = new ServletWebRequest(new MockHttpServletRequest());
  }
View Full Code Here

  }

  @Test
  public void createBinder() throws Exception {
    WebDataBinderFactory factory = createBinderFactory("initBinder", WebDataBinder.class);
    WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);

    assertNotNull(dataBinder.getDisallowedFields());
    assertEquals("id", dataBinder.getDisallowedFields()[0]);
  }
View Full Code Here

  public void createBinderWithGlobalInitialization() throws Exception {
    ConversionService conversionService = new DefaultFormattingConversionService();
    bindingInitializer.setConversionService(conversionService);

    WebDataBinderFactory factory = createBinderFactory("initBinder", WebDataBinder.class);
    WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);

    assertSame(conversionService, dataBinder.getConversionService());
  }
View Full Code Here

  }

  @Test
  public void createBinderWithAttrName() throws Exception {
    WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
    WebDataBinder dataBinder = factory.createBinder(webRequest, null, "foo");

    assertNotNull(dataBinder.getDisallowedFields());
    assertEquals("id", dataBinder.getDisallowedFields()[0]);
  }
View Full Code Here

  }

  @Test
  public void createBinderWithAttrNameNoMatch() throws Exception {
    WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
    WebDataBinder dataBinder = factory.createBinder(webRequest, null, "invalidName");

    assertNull(dataBinder.getDisallowedFields());
  }
View Full Code Here

  }

  @Test
  public void createBinderNullAttrName() throws Exception {
    WebDataBinderFactory factory = createBinderFactory("initBinderWithAttributeName", WebDataBinder.class);
    WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);

    assertNull(dataBinder.getDisallowedFields());
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.bind.WebDataBinder

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.