View Javadoc
1   /**
2    * Copyright 2005-2015 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.labs;
17  
18  import org.kuali.rice.krad.util.GlobalVariables;
19  import org.kuali.rice.krad.web.controller.MethodAccessible;
20  import org.kuali.rice.krad.web.controller.UifControllerBase;
21  import org.kuali.rice.krad.web.form.UifFormBase;
22  import org.kuali.rice.krad.web.service.FileControllerService;
23  import org.springframework.beans.factory.annotation.Autowired;
24  import org.springframework.beans.factory.annotation.Qualifier;
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   * Basic controller for the lab views
37   *
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   */
40  @Controller
41  @RequestMapping(value = "/labs")
42  public class KradLabsController extends UifControllerBase {
43  
44      @Override
45      @RequestMapping(params = "methodToCall=start")
46      public ModelAndView start(UifFormBase form) {
47  
48          if (form.getViewId().equals("Labs-BootstrapMultiSelect")) {
49              GlobalVariables.getMessageMap().putWarning("multiSelectField2", "validation.equals");
50          }
51              return super.start(form);
52       }
53  
54      @Override
55      protected KradLabsForm createInitialForm() {
56          return new KradLabsForm();
57      }
58  
59      @RequestMapping(params = "methodToCall=jsonExample")
60      public ModelAndView jsonExample(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
61              HttpServletRequest request, HttpServletResponse response) {
62  
63          form.setRequestJsonTemplate("/templates/jsonSample.ftl");
64  
65          return getModelAndView(form);
66      }
67  
68      @Autowired
69      @Qualifier("demoFileControllerService")
70      @Override
71      public void setFileControllerService(FileControllerService fileControllerService) {
72          super.setFileControllerService(fileControllerService);
73      }
74  
75      @Override
76      @RequestMapping(method = RequestMethod.POST, params = "methodToCall=saveField")
77      public ModelAndView saveField(UifFormBase uifForm) throws Exception {
78          GlobalVariables.getMessageMap().putError("dataField3", "serverTestError");
79          // Hook method for saving individual fields
80          return refresh(uifForm);
81      }
82  
83      @MethodAccessible
84      @RequestMapping(params = "methodToCall=dialogMessage")
85      public ModelAndView dialogMessage(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
86                  HttpServletRequest request, HttpServletResponse response)  throws Exception {
87          GlobalVariables.getMessageMap().putError("HierarchyMessages", "serverTestError");
88          GlobalVariables.getMessageMap().putError("inputField1", "serverTestError");
89          // Hook method for saving individual fields
90          return getModelAndView(form);
91      }
92  }