Package org.springframework.web.bind

Examples of org.springframework.web.bind.ServletRequestDataBinder


                    paramName + "' is not present but cannot be translated into a null value due to " +
                    "being declared as a primitive type. Consider declaring it as object wrapper type " +
                    "for the corresponding primitive type.");
              }
            }
            ServletRequestDataBinder binder = createBinder(request, null, paramName);
            initBinder(handler, paramName, binder, webRequest, request, response);
            args[i] = binder.convertIfNecessary(paramValue, param.getParameterType(), param);
          }
          else {
            // Bind request parameter onto object...
            if (sessionAttributeSet != null &&
                (sessionAttributeSet.contains(attrName) || sessionAttributeSet.contains(param.getParameterType())) &&
                !implicitModel.containsKey(attrName)) {
              HttpSession session = request.getSession(false);
              if (session == null) {
                throw new HttpSessionRequiredException(
                    "No session found - session required for attribute '" + attrName + "'");
              }
              Object sessionAttr = sessionAttributeStore.retrieveAttribute(webRequest, attrName);
              if (sessionAttr == null) {
                throw new HttpSessionRequiredException(
                    "Session attribute '" + attrName + "' required - not found in session");
              }
              sessionAttrNames.add(attrName);
              implicitModel.addAttribute(attrName, sessionAttr);
            }
            Object bindObject = implicitModel.get(attrName);
            if (bindObject == null) {
              bindObject = BeanUtils.instantiateClass(param.getParameterType());
            }
            ServletRequestDataBinder binder = createBinder(request, bindObject, attrName);
            initBinder(handler, attrName, binder, webRequest, request, response);
            binder.bind(request);
            args[i] = bindObject;
            implicitModel.putAll(binder.getBindingResult().getModel());
            if (args.length > i + 1 && Errors.class.isAssignableFrom(handlerMethod.getParameterTypes()[i + 1])) {
              args[i + 1] = binder.getBindingResult();
              i++;
            }
            else {
              binder.closeNoCatch();
            }
          }
        }
      }
      return args;
View Full Code Here


   * @param command command object, that must be a JavaBean
   * @throws Exception in case of invalid state or arguments
   */
  protected void bind(HttpServletRequest request, Object command) throws Exception {
    logger.debug("Binding request parameters onto MultiActionController command");
    ServletRequestDataBinder binder = createBinder(request, command);
    binder.bind(request);
    if (this.validators != null) {
      for (int i = 0; i < this.validators.length; i++) {
        if (this.validators[i].supports(command.getClass())) {
          ValidationUtils.invokeValidator(this.validators[i], command, binder.getBindingResult());
        }
      }
    }
    binder.closeNoCatch();
  }
View Full Code Here

   * @throws Exception in case of invalid state or arguments
   * @see #bind
   * @see #initBinder
   */
  protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object command) throws Exception {
    ServletRequestDataBinder binder = new ServletRequestDataBinder(command, getCommandName(command));
    initBinder(request, binder);
    return binder;
  }
View Full Code Here

   * @throws Exception in case of invalid state or arguments
   * @see ServletRequestDataBinder#bind(javax.servlet.ServletRequest)
   * @see ServletRequestDataBinder#convertIfNecessary(Object, Class, org.springframework.core.MethodParameter)
   */
  protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object target, String objectName) throws Exception {
    return new ServletRequestDataBinder(target, objectName);
  }
View Full Code Here

          webRequest.getNativeRequest(HttpServletRequest.class), target, objectName);
    }

    @Override
    protected void doBind(WebDataBinder binder, NativeWebRequest webRequest) throws Exception {
      ServletRequestDataBinder servletBinder = (ServletRequestDataBinder) binder;
      servletBinder.bind(webRequest.getNativeRequest(ServletRequest.class));
    }
View Full Code Here

  protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    Object command = getCommand(request);
    ServletRequestDataBinder binder = bindAndValidate(request, command);
    BindException errors = new BindException(binder.getBindingResult());
    return handle(request, response, command, errors);
  }
View Full Code Here

    // Form submission or new form to show?
    if (isFormSubmission(request)) {
      // Fetch form object from HTTP session, bind, validate, process submission.
      try {
        Object command = getCommand(request);
        ServletRequestDataBinder binder = bindAndValidate(request, command);
        BindException errors = new BindException(binder.getBindingResult());
        return processFormSubmission(request, response, command, errors);
      }
      catch (HttpSessionRequiredException ex) {
        // Cannot submit a session form if no form object is in the session.
        if (logger.isDebugEnabled()) {
View Full Code Here

      throw new ServletException("Form object returned by formBackingObject() must match commandClass");
    }

    // Bind without validation, to allow for prepopulating a form, and for
    // convenient error evaluation in views (on both first attempt and resubmit).
    ServletRequestDataBinder binder = createBinder(request, command);
    BindException errors = new BindException(binder.getBindingResult());
    if (isBindOnNewForm()) {
      logger.debug("Binding to new form");
      binder.bind(request);
      onBindOnNewForm(request, command, errors);
    }

    // Return BindException object that resulted from binding.
    return errors;
View Full Code Here

   */
  protected ModelAndView handleInvalidSubmit(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    Object command = formBackingObject(request);
    ServletRequestDataBinder binder = bindAndValidate(request, command);
    BindException errors = new BindException(binder.getBindingResult());
    return processFormSubmission(request, response, command, errors);
  }
View Full Code Here

  public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws Exception {

    ThrowawayController throwaway = (ThrowawayController) handler;

    ServletRequestDataBinder binder = createBinder(request, throwaway);
    binder.bind(request);
    binder.closeNoCatch();

    return throwaway.execute();
  }
View Full Code Here

TOP

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

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.