001    /**
002     * Copyright 2005-2011 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.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/ecl2.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 javax.servlet.http.HttpServletRequest;
019    import javax.servlet.http.HttpServletResponse;
020    
021    import org.kuali.rice.krad.uif.UifParameters;
022    import org.kuali.rice.krad.util.GlobalVariables;
023    import org.kuali.rice.krad.web.controller.UifControllerBase;
024    import org.kuali.rice.krad.web.form.UifFormBase;
025    import org.springframework.stereotype.Controller;
026    import org.springframework.validation.BindingResult;
027    import org.springframework.web.bind.annotation.ModelAttribute;
028    import org.springframework.web.bind.annotation.RequestMapping;
029    import org.springframework.web.bind.annotation.RequestMethod;
030    import org.springframework.web.servlet.ModelAndView;
031    
032    import edu.sampleu.travel.krad.form.UILayoutTestForm;
033    
034    /**
035     * Controller for the Test UI Page
036     * 
037     * @author Kuali Rice Team (rice.collab@kuali.org)
038     */
039    @Controller
040    @RequestMapping(value = "/uicomponents")
041    public class UIComponentsTestController extends UifControllerBase {
042    
043        /**
044         * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
045         */
046        @Override
047        protected UILayoutTestForm createInitialForm(HttpServletRequest request) {
048            return new UILayoutTestForm();
049        }
050    
051            @Override
052            @RequestMapping(params = "methodToCall=start")
053            public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
054                            HttpServletRequest request, HttpServletResponse response) {
055                UILayoutTestForm uiTestForm = (UILayoutTestForm) form;
056    
057                    return super.start(uiTestForm, result, request, response);
058            }
059    
060            @RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
061            public ModelAndView save(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
062                            HttpServletRequest request, HttpServletResponse response) {
063    
064                    return getUIFModelAndView(uiTestForm, "page2");
065            }
066            
067            @RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
068            public ModelAndView close(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
069                            HttpServletRequest request, HttpServletResponse response) {
070    
071                    return getUIFModelAndView(uiTestForm, "page1");
072            }
073    
074        /**
075         * Handles menu navigation between view pages
076         */
077        @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")
078        public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
079                HttpServletRequest request, HttpServletResponse response) {
080            String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
081    
082            if(pageId.equals("uifpage7")){
083                GlobalVariables.getMessageMap().putError("gField1", "serverTestError");
084                GlobalVariables.getMessageMap().putError("gField1", "serverTestError2");
085                GlobalVariables.getMessageMap().putError("gField2", "serverTestError");
086                GlobalVariables.getMessageMap().putError("gField3", "serverTestError");
087                GlobalVariables.getMessageMap().putWarning("gField1", "serverTestWarning");
088                GlobalVariables.getMessageMap().putWarning("gField2", "serverTestWarning");
089                GlobalVariables.getMessageMap().putInfo("gField2", "serverTestInfo");
090                GlobalVariables.getMessageMap().putInfo("gField3", "serverTestInfo");
091            }
092            // only refreshing page
093            form.setRenderFullView(false);
094    
095            return getUIFModelAndView(form, pageId);
096        }
097    
098        @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshProgGroup")
099            public ModelAndView refreshProgGroup(@ModelAttribute("KualiForm") UILayoutTestForm uiTestForm, BindingResult result,
100                            HttpServletRequest request, HttpServletResponse response) {
101    
102                    return updateComponent(uiTestForm, result, request, response);
103            }
104    }