1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs;
17
18 import org.kuali.rice.krad.util.GlobalVariables;
19 import org.kuali.rice.krad.web.controller.MethodAccessible;
20 import org.kuali.rice.krad.web.controller.UifControllerBase;
21 import org.kuali.rice.krad.web.form.UifFormBase;
22 import org.kuali.rice.krad.web.service.FileControllerService;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.beans.factory.annotation.Qualifier;
25 import org.springframework.stereotype.Controller;
26 import org.springframework.validation.BindingResult;
27 import org.springframework.web.bind.annotation.ModelAttribute;
28 import org.springframework.web.bind.annotation.RequestMapping;
29 import org.springframework.web.bind.annotation.RequestMethod;
30 import org.springframework.web.servlet.ModelAndView;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34
35
36
37
38
39
40 @Controller
41 @RequestMapping(value = "/labs")
42 public class KradLabsController extends UifControllerBase {
43
44 @Override
45 @RequestMapping(params = "methodToCall=start")
46 public ModelAndView start(UifFormBase form) {
47
48 if (form.getViewId().equals("Labs-BootstrapMultiSelect")) {
49 GlobalVariables.getMessageMap().putWarning("multiSelectField2", "validation.equals");
50 }
51 return super.start(form);
52 }
53
54 @Override
55 protected KradLabsForm createInitialForm() {
56 return new KradLabsForm();
57 }
58
59 @RequestMapping(params = "methodToCall=jsonExample")
60 public ModelAndView jsonExample(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
61 HttpServletRequest request, HttpServletResponse response) {
62
63 form.setRequestJsonTemplate("/templates/jsonSample.ftl");
64
65 return getModelAndView(form);
66 }
67
68 @Autowired
69 @Qualifier("demoFileControllerService")
70 @Override
71 public void setFileControllerService(FileControllerService fileControllerService) {
72 super.setFileControllerService(fileControllerService);
73 }
74
75 @Override
76 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=saveField")
77 public ModelAndView saveField(UifFormBase uifForm) throws Exception {
78 GlobalVariables.getMessageMap().putError("dataField3", "serverTestError");
79
80 return refresh(uifForm);
81 }
82
83 @MethodAccessible
84 @RequestMapping(params = "methodToCall=dialogMessage")
85 public ModelAndView dialogMessage(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
86 HttpServletRequest request, HttpServletResponse response) throws Exception {
87 GlobalVariables.getMessageMap().putError("HierarchyMessages", "serverTestError");
88 GlobalVariables.getMessageMap().putError("inputField1", "serverTestError");
89
90 return getModelAndView(form);
91 }
92 }