View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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 edu.sampleu.travel.krad.controller;
17  
18  import edu.sampleu.travel.krad.form.UILayoutTestForm;
19  import org.kuali.rice.krad.uif.UifParameters;
20  import org.kuali.rice.krad.util.GlobalVariables;
21  import org.kuali.rice.krad.web.controller.UifControllerBase;
22  import org.kuali.rice.krad.web.form.UifFormBase;
23  import org.springframework.stereotype.Controller;
24  import org.springframework.validation.BindingResult;
25  import org.springframework.web.bind.annotation.ModelAttribute;
26  import org.springframework.web.bind.annotation.RequestMapping;
27  import org.springframework.web.bind.annotation.RequestMethod;
28  import org.springframework.web.servlet.ModelAndView;
29  
30  import javax.servlet.http.HttpServletRequest;
31  import javax.servlet.http.HttpServletResponse;
32  
33  /**
34   * Controller for the Test UI Page
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  @Controller
39  @RequestMapping(value = "/uicomponents")
40  public class UIComponentsTestController extends UifControllerBase {
41  
42      @Override
43      protected Class<UILayoutTestForm> formType() {
44          return UILayoutTestForm.class;
45      }
46  
47  	@Override
48  	@RequestMapping(params = "methodToCall=start")
49  	public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
50  			HttpServletRequest request, HttpServletResponse response) {
51  	    UILayoutTestForm uiTestForm = (UILayoutTestForm) form;
52  
53  		return super.start(uiTestForm, result, request, response);
54  	}
55  
56  	@RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
57  	public ModelAndView save(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
58  			HttpServletRequest request, HttpServletResponse response) {
59  
60  		return getUIFModelAndView(uiTestForm, "page2");
61  	}
62  	
63  	@RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
64  	public ModelAndView close(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
65  			HttpServletRequest request, HttpServletResponse response) {
66  
67  		return getUIFModelAndView(uiTestForm, "page1");
68  	}
69  
70      /**
71       * Handles menu navigation between view pages
72       */
73      @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")
74      public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
75              HttpServletRequest request, HttpServletResponse response) {
76          String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
77  
78          if(pageId.equals("uifpage7")){
79              GlobalVariables.getMessageMap().putError("gField1", "serverTestError");
80              GlobalVariables.getMessageMap().putError("gField1", "serverTestError2");
81              GlobalVariables.getMessageMap().putError("gField2", "serverTestError");
82              GlobalVariables.getMessageMap().putError("gField3", "serverTestError");
83              GlobalVariables.getMessageMap().putWarning("gField1", "serverTestWarning");
84              GlobalVariables.getMessageMap().putWarning("gField2", "serverTestWarning");
85              GlobalVariables.getMessageMap().putInfo("gField2", "serverTestInfo");
86              GlobalVariables.getMessageMap().putInfo("gField3", "serverTestInfo");
87          }
88          // only refreshing page
89          form.setRenderFullView(false);
90  
91          return getUIFModelAndView(form, pageId);
92      }
93  }