1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.controller;
17
18 import org.kuali.rice.krad.demo.uif.form.KradSampleAppForm;
19 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
20 import org.kuali.rice.krad.uif.view.ViewTheme;
21 import org.kuali.rice.krad.util.GlobalVariables;
22 import org.kuali.rice.krad.web.controller.UifControllerBase;
23 import org.kuali.rice.krad.web.form.UifFormBase;
24 import org.springframework.stereotype.Controller;
25 import org.springframework.validation.BindingResult;
26 import org.springframework.web.bind.annotation.ModelAttribute;
27 import org.springframework.web.bind.annotation.RequestMapping;
28 import org.springframework.web.bind.annotation.RequestMethod;
29 import org.springframework.web.servlet.ModelAndView;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33
34
35
36
37
38
39 @Controller
40 @RequestMapping(value = "/kradsampleapp")
41 public class KradSampleAppController extends UifControllerBase {
42
43 @Override
44 protected KradSampleAppForm createInitialForm(HttpServletRequest request) {
45 return new KradSampleAppForm();
46 }
47
48 @Override
49 @RequestMapping(params = "methodToCall=start")
50 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
51 HttpServletRequest request, HttpServletResponse response) {
52
53 return super.start(form, result, request, response);
54 }
55
56 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=changeTheme")
57 public ModelAndView changeTheme(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
58 HttpServletRequest request, HttpServletResponse response) {
59 changeTheme(form);
60 return getUIFModelAndView(form);
61 }
62
63 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView")
64 public ModelAndView validateView(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
65 HttpServletRequest request, HttpServletResponse response) {
66 KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
67 return getUIFModelAndView(uiTestForm);
68 }
69
70 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addGrowl")
71 public ModelAndView addGrowl(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
72 HttpServletRequest request, HttpServletResponse response) {
73 String extraInfo = (String)request.getParameter("extraInfo");
74 if(extraInfo == null){
75 extraInfo = "none";
76 }
77 GlobalVariables.getMessageMap().addGrowlMessage("Growl Message", "demo.fakeGrowl", extraInfo);
78 return getUIFModelAndView(uiTestForm);
79 }
80
81 private void changeTheme(UifFormBase form) {
82 String theme = ((KradSampleAppForm) form).getThemeName();
83 if (theme != null) {
84 ViewTheme newTheme = (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryObject(
85 theme));
86 if (newTheme != null) {
87 form.getPostedView().setTheme(newTheme);
88 form.getView().setTheme(newTheme);
89 }
90 }
91 }
92 }