001 /*
002 * Copyright 2007 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 1.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl1.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.travel.krad.controller;
017
018 import edu.sampleu.travel.krad.form.UILayoutTestForm;
019 import org.kuali.rice.krad.uif.UifParameters;
020 import org.kuali.rice.krad.util.GlobalVariables;
021 import org.kuali.rice.krad.web.controller.UifControllerBase;
022 import org.kuali.rice.krad.web.form.UifFormBase;
023 import org.springframework.stereotype.Controller;
024 import org.springframework.validation.BindingResult;
025 import org.springframework.web.bind.annotation.ModelAttribute;
026 import org.springframework.web.bind.annotation.RequestMapping;
027 import org.springframework.web.bind.annotation.RequestMethod;
028 import org.springframework.web.servlet.ModelAndView;
029
030 import javax.servlet.http.HttpServletRequest;
031 import javax.servlet.http.HttpServletResponse;
032
033 /**
034 * Controller for the Test UI Page
035 *
036 * @author Kuali Rice Team (rice.collab@kuali.org)
037 */
038 @Controller
039 @RequestMapping(value = "/uicomponents")
040 public class UIComponentsTestController extends UifControllerBase {
041
042 @Override
043 protected Class<UILayoutTestForm> formType() {
044 return UILayoutTestForm.class;
045 }
046
047 @Override
048 @RequestMapping(params = "methodToCall=start")
049 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
050 HttpServletRequest request, HttpServletResponse response) {
051 UILayoutTestForm uiTestForm = (UILayoutTestForm) form;
052
053 return super.start(uiTestForm, result, request, response);
054 }
055
056 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
057 public ModelAndView save(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
058 HttpServletRequest request, HttpServletResponse response) {
059
060 return getUIFModelAndView(uiTestForm, "page2");
061 }
062
063 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
064 public ModelAndView close(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
065 HttpServletRequest request, HttpServletResponse response) {
066
067 return getUIFModelAndView(uiTestForm, "page1");
068 }
069
070 /**
071 * Handles menu navigation between view pages
072 */
073 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")
074 public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
075 HttpServletRequest request, HttpServletResponse response) {
076 String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
077
078 if(pageId.equals("uifpage7")){
079 GlobalVariables.getMessageMap().putError("gField1", "serverTestError");
080 GlobalVariables.getMessageMap().putError("gField1", "serverTestError2");
081 GlobalVariables.getMessageMap().putError("gField2", "serverTestError");
082 GlobalVariables.getMessageMap().putError("gField3", "serverTestError");
083 GlobalVariables.getMessageMap().putWarning("gField1", "serverTestWarning");
084 GlobalVariables.getMessageMap().putWarning("gField2", "serverTestWarning");
085 GlobalVariables.getMessageMap().putInfo("gField2", "serverTestInfo");
086 GlobalVariables.getMessageMap().putInfo("gField3", "serverTestInfo");
087 }
088 // only refreshing page
089 form.setRenderFullView(false);
090
091 return getUIFModelAndView(form, pageId);
092 }
093 }