001: /*
002: * Copyright 2005-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005: * in compliance with the License. You may obtain a copy of the License at
006: *
007: * http://www.apache.org/licenses/LICENSE-2.0
008: *
009: * Unless required by applicable law or agreed to in writing, software distributed under the License
010: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011: * or implied. See the License for the specific language governing permissions and limitations under
012: * the License.
013: */
014:
015: package org.strecks.holidaybooking.web.strecks.form;
016:
017: import java.util.Collection;
018:
019: import org.apache.struts.action.ActionForm;
020: import org.strecks.bind.annotation.BindSelect;
021: import org.strecks.bind.annotation.BindSimple;
022: import org.strecks.converter.annotation.ConvertDate;
023: import org.strecks.form.AnnotatedForm;
024: import org.strecks.holidaybooking.domain.HolidayBooking;
025: import org.strecks.holidaybooking.domain.LeaveType;
026: import org.strecks.validator.annotation.ValidateDate;
027: import org.strecks.validator.annotation.ValidateInteger;
028: import org.strecks.validator.annotation.ValidateRequired;
029:
030: /**
031: * @author Phil Zoio
032: */
033: public class HolidayBookingForm extends ActionForm implements
034: AnnotatedForm {
035:
036: private static final long serialVersionUID = -4359715889805708158L;
037:
038: private String title;
039:
040: private String startDate;
041:
042: private String days;
043:
044: private HolidayBooking booking;
045:
046: private boolean editMode;
047:
048: @BindSimple(expression="booking.title")
049: public String getTitle() {
050: return title;
051: }
052:
053: @ValidateRequired(order=1,key="holidaybookingform.title.null")
054: public void setTitle(String title) {
055: this .title = title;
056: }
057:
058: @BindSimple(expression="booking.startDate")
059: @ConvertDate(pattern="yyyy-MM-dd")
060: public String getStartDate() {
061: return startDate;
062: }
063:
064: @ValidateRequired(order=2,key="holidaybookingform.start.date.null")
065: @ValidateDate(key="holidaybookingform.start.date.format")
066: public void setStartDate(String startDate) {
067: this .startDate = startDate;
068: }
069:
070: @BindSimple(expression="booking.days")
071: public String getDays() {
072: return days;
073: }
074:
075: @ValidateRequired(order=3,key="holidaybookingform.days.null")
076: @ValidateInteger(key="holidaybookingform.days.number")
077: public void setDays(String days) {
078: this .days = days;
079: }
080:
081: public HolidayBooking getBooking() {
082: return booking;
083: }
084:
085: public void setBooking(HolidayBooking booking) {
086: this .booking = booking;
087: }
088:
089: public boolean isEditMode() {
090: return editMode;
091: }
092:
093: public void setEditMode(boolean editMode) {
094: this .editMode = editMode;
095: }
096:
097: public String getNextAction() {
098: return (editMode ? "submit_edit_holiday_booking"
099: : "submit_new_holiday_booking");
100: }
101:
102: /** ************** extra leave type selection property ******************* */
103:
104: private Collection<LeaveType> leaveTypes;
105:
106: public Collection<LeaveType> getLeaveTypes() {
107: return leaveTypes;
108: }
109:
110: public void setLeaveTypes(Collection<LeaveType> leaveTypes) {
111: this .leaveTypes = leaveTypes;
112: }
113:
114: private String selectedLeaveType;
115:
116: @BindSelect(targetBeanExpression="booking.leaveType",lookupMapExpression="leaveTypes",targetBeanIdProperty="leaveTypeId",idClass=Integer.class)
117: public String getSelectedLeaveType() {
118: return selectedLeaveType;
119: }
120:
121: @ValidateRequired(order=4,key="holidaybookingform.leaveType.null")
122: public void setSelectedLeaveType(String selectedLeaveType) {
123: this.selectedLeaveType = selectedLeaveType;
124: }
125:
126: }
|