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.student.web.controller; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 021 import javax.servlet.http.HttpServletRequest; 022 import javax.servlet.http.HttpServletResponse; 023 024 import org.kuali.rice.krad.web.controller.UifControllerBase; 025 import org.kuali.rice.krad.web.form.UifFormBase; 026 import org.springframework.stereotype.Controller; 027 import org.springframework.validation.BindingResult; 028 import org.springframework.web.bind.annotation.ModelAttribute; 029 import org.springframework.web.bind.annotation.RequestMapping; 030 import org.springframework.web.bind.annotation.RequestMethod; 031 import org.springframework.web.servlet.ModelAndView; 032 033 import edu.sampleu.student.dataobject.Course; 034 import edu.sampleu.student.dataobject.CourseSection; 035 import edu.sampleu.student.web.form.RegistrationForm; 036 037 /** 038 * @author Kuali Rice Team (rice.collab@kuali.org) 039 */ 040 @Controller 041 @RequestMapping(value = "/registration") 042 public class RegistrationController extends UifControllerBase { 043 044 /** 045 * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest) 046 */ 047 @Override 048 protected RegistrationForm createInitialForm(HttpServletRequest request) { 049 return new RegistrationForm(); 050 } 051 052 /** 053 * Populate some data for demonstration 054 */ 055 @Override 056 @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start") 057 public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, 058 HttpServletRequest request, HttpServletResponse response) { 059 060 RegistrationForm registrationForm = (RegistrationForm) form; 061 registrationForm.setRegistrationTerm("Fall"); 062 registrationForm.setRegistrationYear(2011); 063 064 List<Course> courseListing = new ArrayList<Course>(); 065 066 Course course = new Course(); 067 course.setSubjectId("CTWR"); 068 course.setNumber("106a"); 069 course.setTitle("Screenwriting Fundamentals"); 070 course.setMaxCredits(4); 071 072 CourseSection section = new CourseSection(); 073 section.setSection("001"); 074 section.setRegistrationId("19177D"); 075 section.setStandardMeetingTime("10:00-12:50p | F"); 076 section.setRegisteredNumber(0); 077 section.setWaitlistNumber(1); 078 section.setTotalMaxEnrollment(14); 079 section.setInstructor("Mardik Martin"); 080 section.setLocation("RZC119"); 081 course.getSections().add(section); 082 083 CourseSection section2 = new CourseSection(); 084 section2.setSection("001"); 085 section2.setRegistrationId("19179D"); 086 section2.setStandardMeetingTime("4:00-6:50p | W"); 087 section2.setRegisteredNumber(0); 088 section2.setWaitlistNumber(7); 089 section2.setTotalMaxEnrollment(17); 090 section2.setInstructor("Noreen Stone"); 091 section2.setLocation("RZC119"); 092 course.getSections().add(section2); 093 courseListing.add(course); 094 095 Course course2 = new Course(); 096 course2.setSubjectId("CTWR"); 097 course2.setNumber("206a"); 098 course2.setTitle("Writing the Screenplay"); 099 course2.setMaxCredits(4); 100 course2.getSections().add(section); 101 course2.getSections().add(section2); 102 courseListing.add(course2); 103 104 Course course3 = new Course(); 105 course3.setSubjectId("CTWR"); 106 course3.setNumber("305"); 107 course3.setTitle("Writing To Be Performed"); 108 course3.setMaxCredits(2); 109 course3.getSections().add(section); 110 course3.getSections().add(section2); 111 courseListing.add(course3); 112 courseListing.add(course3); 113 courseListing.add(course3); 114 courseListing.add(course3); 115 courseListing.add(course3); 116 courseListing.add(course3); 117 courseListing.add(course3); 118 courseListing.add(course3); 119 courseListing.add(course3); 120 courseListing.add(course3); 121 courseListing.add(course3); 122 courseListing.add(course3); 123 courseListing.add(course3); 124 courseListing.add(course3); 125 courseListing.add(course3); 126 courseListing.add(course3); 127 courseListing.add(course3); 128 courseListing.add(course3); 129 courseListing.add(course3); 130 courseListing.add(course3); 131 courseListing.add(course3); 132 courseListing.add(course3); 133 courseListing.add(course3); 134 135 registrationForm.setCourseListing(courseListing); 136 137 return super.start(form, result, request, response); 138 } 139 }