Package org.springmodules.xt.examples.mvc.form

Examples of org.springmodules.xt.examples.mvc.form.FileUploadForm


        return FileUploadForm.class.equals(aClass);
    }

    public void validate(Object object, Errors errors) {
        if (this.supports(object.getClass())) {
            FileUploadForm form = (FileUploadForm) object;
           
            if (form.getUploadDir() == null || form.getUploadDir().trim().equals("")) {
                errors.rejectValue("uploadDir", OtherErrorCodes.NO_DIR_CODE, "No directory specified!");
            }
           
            if (form.getFile() == null || form.getFile().isEmpty()) {
                errors.rejectValue("file", OtherErrorCodes.NO_FILE_CODE, "No file selected!");
            }
        }
    }
View Full Code Here


* @author Sergio Bossa
*/
public class FileUploadController extends SimpleFormController {
   
    protected Object formBackingObject(HttpServletRequest request) throws Exception {
        return new FileUploadForm();
    }
View Full Code Here

    protected Object formBackingObject(HttpServletRequest request) throws Exception {
        return new FileUploadForm();
    }

    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
        FileUploadForm form = (FileUploadForm) command;
        String uploadDir = form.getUploadDir();
        MultipartFile file = form.getFile();
       
        file.transferTo(new File(uploadDir + File.separator + file.getOriginalFilename()));
       
        return new AjaxModelAndView(this.getSuccessView(), errors);
    }
View Full Code Here

TOP

Related Classes of org.springmodules.xt.examples.mvc.form.FileUploadForm

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.