1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.fileUploads;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.labs.KradLabsController;
20 import org.kuali.rice.krad.util.GlobalVariables;
21 import org.kuali.rice.krad.util.KRADConstants;
22 import org.kuali.rice.krad.web.form.UifFormBase;
23 import org.springframework.stereotype.Controller;
24 import org.springframework.validation.BindingResult;
25 import org.springframework.web.bind.annotation.ModelAttribute;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.servlet.ModelAndView;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31
32
33
34
35
36
37 @Controller
38 @RequestMapping(value = "/fileUploads")
39 public class LabsFileUploadsController extends KradLabsController {
40
41 @Override
42 protected LabsFileUploadsForm createInitialForm() {
43 return new LabsFileUploadsForm();
44 }
45
46 @RequestMapping(params = "methodToCall=uploadOne")
47 public ModelAndView uploadOne(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
48 HttpServletRequest request, HttpServletResponse response) {
49 LabsFileUploadsForm uploadForm = (LabsFileUploadsForm) form;
50
51 if ((uploadForm.getUploadOne() == null) || StringUtils.isBlank(uploadForm.getUploadOne().getName())) {
52 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "labs.fileUpload", "one");
53 }
54
55 return getModelAndView(form);
56 }
57
58 @RequestMapping(params = "methodToCall=uploadTwo")
59 public ModelAndView uploadTwo(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
60 HttpServletRequest request, HttpServletResponse response) {
61 LabsFileUploadsForm uploadForm = (LabsFileUploadsForm) form;
62
63 if ((uploadForm.getUploadTwo() == null) || StringUtils.isBlank(uploadForm.getUploadTwo().getName())) {
64 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, "labs.fileUpload", "two");
65 }
66
67 return getModelAndView(form);
68 }
69 }