Package org.springframework.web.bind

Examples of org.springframework.web.bind.WebDataBinder


    verify(factory).createBinder(webRequest, target, expectedAttributeName);
  }

  @Test
  public void resovleArgumentViaDefaultConstructor() throws Exception {
    WebDataBinder dataBinder = new WebRequestDataBinder(null);

    WebDataBinderFactory factory = mock(WebDataBinderFactory.class);
    given(factory.createBinder((NativeWebRequest) anyObject(), notNull(), eq("attrName"))).willReturn(dataBinder);

    processor.resolveArgument(paramNamedValidModelAttr, mavContainer, webRequest, factory);
View Full Code Here


    String attrName = "attr1";
    Object attrValue = new Object();
    ModelAndViewContainer mavContainer = new ModelAndViewContainer();
    mavContainer.addAttribute(attrName, attrValue);

    WebDataBinder dataBinder = new WebDataBinder(attrValue, attrName);
    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, attrValue, attrName)).willReturn(dataBinder);

    ModelFactory modelFactory = new ModelFactory(null, binderFactory, sessionAttrsHandler);
    modelFactory.updateModel(webRequest, mavContainer);

    assertEquals(attrValue, mavContainer.getModel().remove(attrName));
    assertSame(dataBinder.getBindingResult(), mavContainer.getModel().remove(bindingResultKey(attrName)));
    assertEquals(0, mavContainer.getModel().size());
  }
View Full Code Here

    sessionAttributeStore.storeAttribute(webRequest, attrName, attrValue);

    // Resolve successfully handler session attribute once
    assertTrue(sessionAttrsHandler.isHandlerSessionAttribute(attrName, null));

    WebDataBinder dataBinder = new WebDataBinder(attrValue, attrName);
    WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
    given(binderFactory.createBinder(webRequest, attrValue, attrName)).willReturn(dataBinder);

    ModelFactory modelFactory = new ModelFactory(null, binderFactory, sessionAttrsHandler);
    modelFactory.updateModel(webRequest, mavContainer);
View Full Code Here

      }
      else if (pathVarName != null) {
        args[i] = resolvePathVariable(pathVarName, methodParam, webRequest, handler);
      }
      else if (attrName != null) {
        WebDataBinder binder =
            resolveModelAttribute(attrName, methodParam, implicitModel, webRequest, handler);
        boolean assignBindingResult = (args.length > i + 1 && Errors.class.isAssignableFrom(paramTypes[i + 1]));
        if (binder.getTarget() != null) {
          doBind(binder, webRequest, validate, !assignBindingResult);
        }
        args[i] = binder.getTarget();
        if (assignBindingResult) {
          args[i + 1] = binder.getBindingResult();
          i++;
        }
        implicitModel.putAll(binder.getBindingResult().getModel());
      }
    }

    return args;
  }
View Full Code Here

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

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

      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

      }
      if (!attrName.startsWith(BindingResult.MODEL_KEY_PREFIX) &&
          (isSessionAttr || isBindingCandidate(attrValue))) {
        String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + attrName;
        if (mavModel != null && !model.containsKey(bindingResultKey)) {
          WebDataBinder binder = createBinder(webRequest, attrValue, attrName);
          initBinder(handler, attrName, binder, webRequest);
          mavModel.put(bindingResultKey, binder.getBindingResult());
        }
      }
    }
  }
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.