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.demo.uif.form.ServerPagingTestForm;
20 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
21 import org.kuali.rice.krad.uif.view.ViewTheme;
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 = "/serverpaging")
41 public class ServerPagingTestController extends UifControllerBase {
42
43 @Override
44 protected ServerPagingTestForm createInitialForm(HttpServletRequest request) {
45 ServerPagingTestForm form = new ServerPagingTestForm();
46 form.setViewId("Demo-CollectionServerPaging-View");
47
48 return form;
49 }
50
51 @Override
52 @RequestMapping(params = "methodToCall=start")
53 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
54 HttpServletRequest request, HttpServletResponse response) {
55 return super.start(form, result, request, response);
56 }
57
58 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=changeTheme")
59 public ModelAndView changeTheme(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
60 HttpServletRequest request, HttpServletResponse response) {
61 changeTheme(form);
62
63 return getUIFModelAndView(form);
64 }
65
66 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView")
67 public ModelAndView validateView(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
68 HttpServletRequest request, HttpServletResponse response) {
69 KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
70
71 return getUIFModelAndView(uiTestForm);
72 }
73
74 private void changeTheme(UifFormBase form) {
75 String theme = ((KradSampleAppForm) form).getThemeName();
76 if (theme != null) {
77 ViewTheme newTheme = (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryObject(
78 theme));
79
80 if (newTheme != null) {
81 form.getPostedView().setTheme(newTheme);
82 form.getView().setTheme(newTheme);
83 }
84 }
85 }
86 }