View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Controller for the server paging component library page
36   *
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  @Controller
40  @RequestMapping(value = "/serverpaging")
41  public class ServerPagingTestController extends UifControllerBase {
42  
43      @Override
44      protected ServerPagingTestForm createInitialForm() {
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(UifFormBase form) {
54          return super.start(form);
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  
62          return getModelAndView(form);
63      }
64  
65      @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView")
66      public ModelAndView validateView(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result,
67              HttpServletRequest request, HttpServletResponse response) {
68          KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm);
69  
70          return getModelAndView(uiTestForm);
71      }
72  
73      private void changeTheme(UifFormBase form) {
74          String theme = ((KradSampleAppForm) form).getThemeName();
75          if (theme != null) {
76              ViewTheme newTheme = (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryBean(
77                      theme));
78  
79              if (newTheme != null) {
80                  form.getView().setTheme(newTheme);
81              }
82          }
83      }
84  }