001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.krad.demo.uif.controller; 017 018import org.kuali.rice.krad.demo.uif.form.KradSampleAppForm; 019import org.kuali.rice.krad.demo.uif.form.ServerPagingTestForm; 020import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 021import org.kuali.rice.krad.uif.view.ViewTheme; 022import org.kuali.rice.krad.web.controller.UifControllerBase; 023import org.kuali.rice.krad.web.form.UifFormBase; 024import org.springframework.stereotype.Controller; 025import org.springframework.validation.BindingResult; 026import org.springframework.web.bind.annotation.ModelAttribute; 027import org.springframework.web.bind.annotation.RequestMapping; 028import org.springframework.web.bind.annotation.RequestMethod; 029import org.springframework.web.servlet.ModelAndView; 030 031import javax.servlet.http.HttpServletRequest; 032import javax.servlet.http.HttpServletResponse; 033 034/** 035 * Controller for the server paging component library page 036 * 037 * @author Kuali Rice Team (rice.collab@kuali.org) 038 */ 039@Controller 040@RequestMapping(value = "/serverpaging") 041public class ServerPagingTestController extends UifControllerBase { 042 043 @Override 044 protected ServerPagingTestForm createInitialForm(HttpServletRequest request) { 045 ServerPagingTestForm form = new ServerPagingTestForm(); 046 form.setViewId("Demo-CollectionServerPaging-View"); 047 048 return form; 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 return super.start(form, result, request, response); 056 } 057 058 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=changeTheme") 059 public ModelAndView changeTheme(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 060 HttpServletRequest request, HttpServletResponse response) { 061 changeTheme(form); 062 063 return getUIFModelAndView(form); 064 } 065 066 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=validateView") 067 public ModelAndView validateView(@ModelAttribute("KualiForm") UifFormBase uiTestForm, BindingResult result, 068 HttpServletRequest request, HttpServletResponse response) { 069 KRADServiceLocatorWeb.getViewValidationService().validateView(uiTestForm); 070 071 return getUIFModelAndView(uiTestForm); 072 } 073 074 private void changeTheme(UifFormBase form) { 075 String theme = ((KradSampleAppForm) form).getThemeName(); 076 if (theme != null) { 077 ViewTheme newTheme = (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryObject( 078 theme)); 079 080 if (newTheme != null) { 081 form.getPostedView().setTheme(newTheme); 082 form.getView().setTheme(newTheme); 083 } 084 } 085 } 086}