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.BasicFormAction;
18: import org.strecks.action.basic.BasicFormController;
19: import org.strecks.controller.annotation.Controller;
20: import org.strecks.exceptions.StaleSessionException;
21: import org.strecks.holidaybooking.domain.HolidayBooking;
22: import org.strecks.holidaybooking.service.HolidayBookingService;
23: import org.strecks.holidaybooking.web.strecks.form.HolidayBookingForm;
24: import org.strecks.injection.annotation.InjectActionForm;
25: import org.strecks.injection.annotation.InjectRequestParameter;
26: import org.strecks.injection.annotation.InjectSpringBean;
27:
28: /**
29: * @author Phil Zoio
30: */
31: @Controller(name=BasicFormController.class)
32: public class EditBookingAction implements BasicFormAction {
33:
34: private boolean inputError;
35:
36: private Long holidayBookingId;
37:
38: private HolidayBookingService holidayBookingService;
39:
40: private HolidayBookingForm form;
41:
42: public String execute() {
43: if (!isInputError()) {
44: if (holidayBookingId == null)
45: throw new StaleSessionException();
46: HolidayBooking holidayBooking = holidayBookingService
47: .getHolidayBooking(holidayBookingId);
48: form.setBooking(holidayBooking);
49:
50: //add support for selecting a leave type
51: form.setLeaveTypes(holidayBookingService.getLeaveTypes());
52:
53: form.setEditMode(true);
54: }
55: return "success";
56: }
57:
58: public boolean isInputError() {
59: return inputError;
60: }
61:
62: public void setInputError(boolean inputError) {
63: this .inputError = inputError;
64: }
65:
66: @InjectRequestParameter
67: public void setHolidayBookingId(Long holidayBookingId) {
68: this .holidayBookingId = holidayBookingId;
69: }
70:
71: @InjectSpringBean(name="holidayBookingService")
72: public void setHolidayBookingService(
73: HolidayBookingService holidayBookingService) {
74: this .holidayBookingService = holidayBookingService;
75: }
76:
77: @InjectActionForm
78: public void setForm(HolidayBookingForm form) {
79: this.form = form;
80: }
81:
82: }
|