View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.webflow.samples.booking;
20  
21  import java.util.List;
22  
23  import org.springframework.beans.factory.annotation.Autowired;
24  import org.springframework.stereotype.Controller;
25  import org.springframework.ui.Model;
26  import org.springframework.web.bind.annotation.PathVariable;
27  import org.springframework.web.bind.annotation.RequestMapping;
28  import org.springframework.web.bind.annotation.RequestMethod;
29  
30  @Controller
31  public class BookingsController {
32  
33      private TravelService travelService;
34  
35      @Autowired
36      public BookingsController(TravelService travelService) {
37  	this.travelService = travelService;
38      }
39  
40      @RequestMapping(value = "/{userName}/bookings", method = RequestMethod.GET)
41      public void getDashboard(@PathVariable("userName") String userName, Model model) {
42  	List<Booking> booking = travelService.findBookings(userName);
43  	model.addAttribute(booking);
44      }
45  
46      @RequestMapping(value = "/{userName}/bookings/{id}", method = RequestMethod.DELETE)
47      public String deleteBooking(@PathVariable("id") Long id) {
48  	travelService.cancelBooking(id);
49  	return "redirect:/dashboard";
50      }
51  }