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.action.basic.impl;
016:
017: import org.apache.struts.action.ActionForm;
018: import org.strecks.bind.annotation.BindSelect;
019: import org.strecks.bind.annotation.BindSimple;
020: import org.strecks.converter.annotation.ConvertDate;
021: import org.strecks.form.AnnotatedForm;
022: import org.strecks.validator.annotation.ValidateDate;
023: import org.strecks.validator.annotation.ValidateInteger;
024: import org.strecks.validator.annotation.ValidateRequired;
025:
026: /**
027: * @author Phil Zoio
028: */
029: public class HolidayBookingForm extends ActionForm implements
030: AnnotatedForm {
031:
032: private static final long serialVersionUID = -4359715889805708158L;
033:
034: private String title;
035:
036: private String startDate;
037:
038: private String days;
039:
040: private HolidayBooking booking;
041:
042: private boolean editMode;
043:
044: @BindSimple(expression="booking.title")
045: public String getTitle() {
046: return title;
047: }
048:
049: @ValidateRequired(order=1,key="holidaybookingform.title.null")
050: public void setTitle(String title) {
051: this .title = title;
052: }
053:
054: @BindSimple(expression="booking.startDate")
055: @ConvertDate(pattern="yyyy-MM-dd")
056: public String getStartDate() {
057: return startDate;
058: }
059:
060: @ValidateRequired(order=2,key="holidaybookingform.start.date.null")
061: @ValidateDate(key="holidaybookingform.start.date.format")
062: public void setStartDate(String startDate) {
063: this .startDate = startDate;
064: }
065:
066: @BindSimple(expression="booking.days")
067: public String getDays() {
068: return days;
069: }
070:
071: @ValidateRequired(order=3,key="holidaybookingform.days.null")
072: @ValidateInteger(key="holidaybookingform.days.number")
073: public void setDays(String days) {
074: this .days = days;
075: }
076:
077: public HolidayBooking getBooking() {
078: return booking;
079: }
080:
081: public void setBooking(HolidayBooking booking) {
082: this .booking = booking;
083: }
084:
085: public boolean isEditMode() {
086: return editMode;
087: }
088:
089: public void setEditMode(boolean editMode) {
090: this .editMode = editMode;
091: }
092:
093: public String getNextAction() {
094: return (editMode ? "submit_edit_holiday_booking"
095: : "submit_new_holiday_booking");
096: }
097:
098: /** ************** extra leave type selection property ******************* */
099:
100: private String selectedLeaveType;
101:
102: @BindSelect(targetBeanExpression="booking.leaveType",lookupMapExpression="leaveTypes",targetBeanIdProperty="leaveTypeId",idClass=Integer.class)
103: public String getSelectedLeaveType() {
104: return selectedLeaveType;
105: }
106:
107: @ValidateRequired(order=4,key="holidaybookingform.leaveType.null")
108: public void setSelectedLeaveType(String selectedLeaveType) {
109: this.selectedLeaveType = selectedLeaveType;
110: }
111:
112: }
|