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