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.util.ComponentFactory;
21 import org.kuali.rice.krad.uif.view.ViewTheme;
22 import org.kuali.rice.krad.util.GlobalVariables;
23 import org.kuali.rice.krad.web.controller.UifControllerBase;
24 import org.kuali.rice.krad.web.form.UifFormBase;
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 = "/kradsampleapp")
42 public class KradSampleAppController extends UifControllerBase {
43
44 @Override
45 protected KradSampleAppForm createInitialForm(HttpServletRequest request) {
46 return new KradSampleAppForm();
47 }
48
49 @Override
50 @RequestMapping(params = "methodToCall=start")
51 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
52 HttpServletRequest request, HttpServletResponse response) {
53
54 return super.start(form, result, request, response);
55 }
56
57 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=changeTheme")
58 public ModelAndView changeTheme(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
59 HttpServletRequest request, HttpServletResponse response) {
60 changeTheme(form);
61 return getUIFModelAndView(form);
62 }
63
64 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView")
65 public ModelAndView validateView(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
66 HttpServletRequest request, HttpServletResponse response) {
67 KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
68 return getUIFModelAndView(uiTestForm);
69 }
70
71 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addGrowl")
72 public ModelAndView addGrowl(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
73 HttpServletRequest request, HttpServletResponse response) {
74 String extraInfo = (String)request.getParameter("extraInfo");
75 if(extraInfo == null){
76 extraInfo = "none";
77 }
78 GlobalVariables.getMessageMap().addGrowlMessage("Growl Message", "demo.fakeGrowl", extraInfo);
79 return getUIFModelAndView(uiTestForm);
80 }
81
82 private void changeTheme(UifFormBase form) {
83 String theme = ((KradSampleAppForm) form).getThemeName();
84 if (theme != null) {
85 ViewTheme newTheme = (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryObject(
86 theme));
87 if (newTheme != null) {
88 form.getPostedView().setTheme(newTheme);
89 form.getView().setTheme(newTheme);
90 }
91 }
92 }
93 }