01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.holidaybooking.web.strecks.action;
16:
17: import org.strecks.action.BasicSubmitAction;
18: import org.strecks.action.basic.BasicSubmitController;
19: import org.strecks.controller.annotation.Controller;
20: import org.strecks.holidaybooking.domain.HolidayBooking;
21: import org.strecks.holidaybooking.service.HolidayBookingService;
22: import org.strecks.holidaybooking.web.strecks.form.HolidayBookingForm;
23: import org.strecks.injection.annotation.InjectActionForm;
24: import org.strecks.injection.annotation.InjectSpringBean;
25: import org.strecks.injection.annotation.InjectWebHelper;
26: import org.strecks.web.WebHelper;
27:
28: /**
29: * @author Phil Zoio
30: */
31: @Controller(name=BasicSubmitController.class)
32: public class SubmitEditBookingAction implements BasicSubmitAction {
33:
34: private HolidayBookingForm form;
35:
36: private HolidayBookingService holidayBookingService;
37:
38: private WebHelper webHelper;
39:
40: public void preBind() {
41: }
42:
43: public String cancel() {
44: webHelper.setRequestAttribute("displayMessage",
45: "Cancelled operation");
46: webHelper.removeSessionAttribute("holidayBookingForm");
47: return "success";
48: }
49:
50: public String execute() {
51: HolidayBooking holidayBooking = form.getBooking();
52: holidayBookingService.updateHolidayBooking(holidayBooking);
53:
54: webHelper.setRequestAttribute("displayMessage",
55: "Successfully updated entry: "
56: + holidayBooking.getTitle());
57: webHelper.removeSessionAttribute("holidayBookingForm");
58:
59: return "success";
60: }
61:
62: @InjectActionForm
63: public void setForm(HolidayBookingForm form) {
64: this .form = form;
65: }
66:
67: @InjectSpringBean(name="holidayBookingService")
68: public void setHolidayBookingService(
69: HolidayBookingService holidayBookingService) {
70: this .holidayBookingService = holidayBookingService;
71: }
72:
73: @InjectWebHelper
74: public void setWebHelper(WebHelper webHelper) {
75: this.webHelper = webHelper;
76: }
77:
78: }
|