Package org.springframework.web.bind

Examples of org.springframework.web.bind.ServletRequestDataBinder


     * Binds properties from the request parameters to the given POJO which is
     * useful for POJOs which are configurable via request parameters such as
     * for query/view POJOs
     */
    protected Object bindRequestBean(Object bean, ServletRequest request) {
        ServletRequestDataBinder binder = new ServletRequestDataBinder(bean, null);
        binder.bind(request);
        return bean;
    }
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

     * @throws Exception in case of invalid state or arguments
     */
    protected final ServletRequestDataBinder bindAndValidate(HttpServletRequest request, Object command)
            throws Exception {

        ServletRequestDataBinder binder = createBinder(request, command);
        BindException errors = new BindException(binder.getBindingResult());
        if (!suppressBinding(request)) {
            binder.bind(request);
            onBind(request, command, errors);
            if (this.validators != null && isValidateOnBinding() && !suppressValidation(request, command, errors)) {
                for (int i = 0; i < this.validators.length; i++) {
                    ValidationUtils.invokeValidator(this.validators[i], command, errors);
                }
View Full Code Here

     * @see #initBinder
     */
    protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object command)
        throws Exception {

        ServletRequestDataBinder binder = new ServletRequestDataBinder(command, getCommandName());
        prepareBinder(binder);
        initBinder(request, binder);
        return binder;
    }
View Full Code Here

        if (object instanceof String) {
            String handlerName = (String)object;
            object = getApplicationContext().getBean(handlerName);
        }

        ServletRequestDataBinder binder = new ServletRequestDataBinder(object, "request");
        binder.bind(request);
        binder.setIgnoreUnknownFields(true);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Bound POJO is now: " + object);
        }
        return object;
    }
View Full Code Here

    }


    private BindingResult doBind(HttpServletRequest webRequest, Class<? extends RopRequest> requestType) {
        RopRequest bindObject = BeanUtils.instantiateClass(requestType);
        ServletRequestDataBinder dataBinder = new ServletRequestDataBinder(bindObject, "bindObject");
        dataBinder.setConversionService(getFormattingConversionService());
        dataBinder.setValidator(getValidator());
        dataBinder.bind(webRequest);
        dataBinder.validate();
        return dataBinder.getBindingResult();
    }
View Full Code Here

     * Binds properties from the request parameters to the given POJO which is
     * useful for POJOs which are configurable via request parameters such as
     * for query/view POJOs
     */
    protected Object bindRequestBean(Object bean, ServletRequest request) {
        ServletRequestDataBinder binder = new ServletRequestDataBinder(bean, null);
        binder.bind(request);
        return bean;
    }
View Full Code Here

                    !request.getSession().getAttribute("secret").equals(request.getParameter("secret"))) {
                    throw new UnsupportedOperationException("Possible CSRF attack");
                }
            }

            ServletRequestDataBinder binder = new ServletRequestDataBinder(object, "request");
            try {
                binder.bind(request);
                binder.setIgnoreUnknownFields(true);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Bound POJO is now: " + object);
                }
            }
            catch (Exception e) {
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.