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.InjectWebHelper;
25: import org.strecks.injection.annotation.InjectSpringBean;
26: import org.strecks.web.WebHelper;
27:
28: /**
29: * @author Phil Zoio
30: */
31: @Controller(name=BasicSubmitController.class)
32: public class SubmitNewBookingAction implements BasicSubmitAction {
33:
34: private HolidayBookingForm form;
35:
36: private HolidayBookingService holidayBookingService;
37:
38: private WebHelper webHelper;
39:
40: public void preBind() {
41: form.setBooking(new HolidayBooking());
42: }
43:
44: public String cancel() {
45: webHelper.setRequestAttribute("displayMessage",
46: "Cancelled operation");
47: webHelper.removeSessionAttribute("holidayBookingForm");
48: return "success";
49: }
50:
51: public String execute() {
52: HolidayBooking holidayBooking = form.getBooking();
53: holidayBookingService.addHolidayBooking(holidayBooking);
54:
55: webHelper.setRequestAttribute("displayMessage",
56: "Successfully added entry: "
57: + holidayBooking.getTitle());
58: webHelper.removeSessionAttribute("holidayBookingForm");
59:
60: return "success";
61: }
62:
63: @InjectActionForm
64: public void setForm(HolidayBookingForm form) {
65: this .form = form;
66: }
67:
68: @InjectSpringBean(name="holidayBookingService")
69: public void setHolidayBookingService(
70: HolidayBookingService holidayBookingService) {
71: this .holidayBookingService = holidayBookingService;
72: }
73:
74: @InjectWebHelper
75: public void setWebHelper(WebHelper webHelper) {
76: this.webHelper = webHelper;
77: }
78:
79: }
|