View Javadoc

1   /**
2    * Copyright 2005-2012 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 edu.sampleu.demo.kitchensink;
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  /**
33   * Controller for the Test UI Page
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @Controller
38  @RequestMapping(value = "/uicomponents")
39  public class UifComponentsTestController extends UifControllerBase {
40  
41      /**
42       * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
43       */
44      @Override
45      protected UifComponentsTestForm createInitialForm(HttpServletRequest request) {
46          return new UifComponentsTestForm();
47      }
48  
49  	@Override
50  	@RequestMapping(params = "methodToCall=start")
51  	public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
52  			HttpServletRequest request, HttpServletResponse response) {
53  	    UifComponentsTestForm uiTestForm = (UifComponentsTestForm) form;
54  
55  		return super.start(uiTestForm, result, request, response);
56  	}
57  
58  	@RequestMapping(method = RequestMethod.POST, params = "methodToCall=save")
59  	public ModelAndView save(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
60  			HttpServletRequest request, HttpServletResponse response) {
61  
62  		return getUIFModelAndView(uiTestForm);
63  	}
64  	
65  	@RequestMapping(method = RequestMethod.POST, params = "methodToCall=close")
66  	public ModelAndView close(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
67  			HttpServletRequest request, HttpServletResponse response) {
68  
69  		return getUIFModelAndView(uiTestForm, "UifCompView-Page1");
70  	}
71  
72      /**
73       * Handles menu navigation between view pages
74       */
75      @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")
76      public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
77              HttpServletRequest request, HttpServletResponse response) {
78          String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);
79  
80          if(pageId.equals("UifCompView-Page8")){
81              GlobalVariables.getMessageMap().putError("gField1", "serverTestError");
82              GlobalVariables.getMessageMap().putError("gField1", "serverTestError2");
83              GlobalVariables.getMessageMap().putError("gField2", "serverTestError");
84              GlobalVariables.getMessageMap().putError("gField3", "serverTestError");
85              GlobalVariables.getMessageMap().putWarning("gField1", "serverTestWarning");
86              GlobalVariables.getMessageMap().putWarning("gField2", "serverTestWarning");
87              GlobalVariables.getMessageMap().putInfo("gField2", "serverTestInfo");
88              GlobalVariables.getMessageMap().putInfo("gField3", "serverTestInfo");
89          }
90          // only refreshing page
91          form.setRenderFullView(false);
92  
93          return getUIFModelAndView(form, pageId);
94      }
95  
96      @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshProgGroup")
97  	public ModelAndView refreshProgGroup(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
98  			HttpServletRequest request, HttpServletResponse response) {
99  
100 		return updateComponent(uiTestForm, result, request, response);
101 	}
102 
103     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=refreshWithServerMessages")
104 	public ModelAndView refreshWithServerMessages(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
105 			HttpServletRequest request, HttpServletResponse response) {
106         GlobalVariables.getMessageMap().putError("field45", "serverTestError");
107         GlobalVariables.getMessageMap().putWarning("field45", "serverTestWarning");
108         GlobalVariables.getMessageMap().putInfo("field45", "serverTestInfo");
109 		return updateComponent(uiTestForm, result, request, response);
110 	}
111 
112     @RequestMapping(method = RequestMethod.POST, params = "methodToCall=genCollectionServerMessages")
113 	public ModelAndView genCollectionServerMessages(@ModelAttribute("KualiForm") UifComponentsTestForm uiTestForm, BindingResult result,
114 			HttpServletRequest request, HttpServletResponse response) throws Exception{
115         GlobalVariables.getMessageMap().putError("list2[0].field1", "serverTestError");
116         GlobalVariables.getMessageMap().putWarning("list2[0].field1", "serverTestWarning");
117         GlobalVariables.getMessageMap().putInfo("list2[0].field1", "serverTestInfo");
118 
119         GlobalVariables.getMessageMap().putError("list3[0].field1", "serverTestError");
120         GlobalVariables.getMessageMap().putWarning("list3[0].field1", "serverTestWarning");
121         GlobalVariables.getMessageMap().putInfo("list3[0].field1", "serverTestInfo");
122 
123         GlobalVariables.getMessageMap().putError("list5[0].subList[0].field1", "serverTestError");
124         GlobalVariables.getMessageMap().putWarning("list5[0].subList[0].field1", "serverTestWarning");
125         GlobalVariables.getMessageMap().putInfo("list5[0].subList[0].field1", "serverTestInfo");
126 		return refresh(uiTestForm, result, request, response);
127 	}
128 }