1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.demo.kitchensink;
17
18 import javax.servlet.http.HttpServletRequest;
19 import javax.servlet.http.HttpServletResponse;
20
21 import org.kuali.rice.krad.datadictionary.validation.ViewAttributeValueReader;
22 import org.kuali.rice.krad.service.DictionaryValidationService;
23 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
24 import org.kuali.rice.krad.uif.UifParameters;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.web.controller.UifControllerBase;
27 import org.kuali.rice.krad.web.form.UifFormBase;
28 import org.springframework.stereotype.Controller;
29 import org.springframework.validation.BindingResult;
30 import org.springframework.web.bind.annotation.ModelAttribute;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.RequestMethod;
33 import org.springframework.web.servlet.ModelAndView;
34
35
36
37
38
39
40 @Controller
41 @RequestMapping(value = "/uicomponents")
42 public class UifComponentsTestController extends UifControllerBase {
43
44
45
46
47
48
49 @Override
50 protected UifComponentsTestForm createInitialForm(HttpServletRequest request) {
51 return new UifComponentsTestForm();
52 }
53
54 @Override
55 @RequestMapping(params = "methodToCall=start")
56 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
57 HttpServletRequest request, HttpServletResponse response) {
58 UifComponentsTestForm uiTestForm = (UifComponentsTestForm) form;
59
60 return super.start(uiTestForm, result, request, response);
61 }
62
63 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
64 public ModelAndView save(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
65 HttpServletRequest request, HttpServletResponse response) {
66 KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
67 return getUIFModelAndView(uiTestForm);
68 }
69
70
71 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
72 public ModelAndView close(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
73 HttpServletRequest request, HttpServletResponse response) {
74
75 return getUIFModelAndView(uiTestForm, "UifCompView-Page1");
76 }
77
78
79
80
81 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")
82 public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
83 HttpServletRequest request, HttpServletResponse response) {
84 String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
85
86 if (pageId.equals("UifCompView-Page8")) {
87 GlobalVariables.getMessageMap().putError("gField1", "serverTestError");
88 GlobalVariables.getMessageMap().putError("gField1", "serverTestError2");
89 GlobalVariables.getMessageMap().putError("gField2", "serverTestError");
90 GlobalVariables.getMessageMap().putError("gField3", "serverTestError");
91 GlobalVariables.getMessageMap().putWarning("gField1", "serverTestWarning");
92 GlobalVariables.getMessageMap().putWarning("gField2", "serverTestWarning");
93 GlobalVariables.getMessageMap().putInfo("gField2", "serverTestInfo");
94 GlobalVariables.getMessageMap().putInfo("gField3", "serverTestInfo");
95 }
96
97 form.setRenderFullView(false);
98
99 return getUIFModelAndView(form, pageId);
100 }
101
102 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshProgGroup")
103 public ModelAndView refreshProgGroup(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm,
104 BindingResult result, HttpServletRequest request, HttpServletResponse response) {
105
106 return updateComponent(uiTestForm, result, request, response);
107 }
108
109 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshWithServerMessages")
110 public ModelAndView refreshWithServerMessages(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm,
111 BindingResult result, HttpServletRequest request, HttpServletResponse response) {
112 GlobalVariables.getMessageMap().putError("field45", "serverTestError");
113 GlobalVariables.getMessageMap().putWarning("field45", "serverTestWarning");
114 GlobalVariables.getMessageMap().putInfo("field45", "serverTestInfo");
115 return updateComponent(uiTestForm, result, request, response);
116 }
117
118 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=genCollectionServerMessages")
119 public ModelAndView genCollectionServerMessages(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm,
120 BindingResult result, HttpServletRequest request, HttpServletResponse response) throws Exception {
121 GlobalVariables.getMessageMap().putError("list2[0].field1", "serverTestError");
122 GlobalVariables.getMessageMap().putWarning("list2[0].field1", "serverTestWarning");
123 GlobalVariables.getMessageMap().putInfo("list2[0].field1", "serverTestInfo");
124
125 GlobalVariables.getMessageMap().putError("list3[0].field1", "serverTestError");
126 GlobalVariables.getMessageMap().putWarning("list3[0].field1", "serverTestWarning");
127 GlobalVariables.getMessageMap().putInfo("list3[0].field1", "serverTestInfo");
128
129 GlobalVariables.getMessageMap().putError("list5[0].subList[0].field1", "serverTestError");
130 GlobalVariables.getMessageMap().putWarning("list5[0].subList[0].field1", "serverTestWarning");
131 GlobalVariables.getMessageMap().putInfo("list5[0].subList[0].field1", "serverTestInfo");
132 return refresh(uiTestForm, result, request, response);
133 }
134 }