Package org.strecks.holidaybooking.web.strecks.action

Source Code of org.strecks.holidaybooking.web.strecks.action.EditBookingAction

/*
* Copyright 2005-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package org.strecks.holidaybooking.web.strecks.action;

import org.strecks.action.BasicFormAction;
import org.strecks.action.basic.BasicFormController;
import org.strecks.controller.annotation.Controller;
import org.strecks.exceptions.StaleSessionException;
import org.strecks.holidaybooking.domain.HolidayBooking;
import org.strecks.holidaybooking.service.HolidayBookingService;
import org.strecks.holidaybooking.web.strecks.form.HolidayBookingForm;
import org.strecks.injection.annotation.InjectActionForm;
import org.strecks.injection.annotation.InjectRequestParameter;
import org.strecks.injection.annotation.InjectSpringBean;

/**
* @author Phil Zoio
*/
@Controller(name = BasicFormController.class)
public class EditBookingAction implements BasicFormAction
{

  private boolean inputError;

  private Long holidayBookingId;

  private HolidayBookingService holidayBookingService;

  private HolidayBookingForm form;

  public String execute()
  {
    if (!isInputError())
    {
      if (holidayBookingId == null) throw new StaleSessionException();
      HolidayBooking holidayBooking = holidayBookingService.getHolidayBooking(holidayBookingId);
      form.setBooking(holidayBooking);

      //add support for selecting a leave type
      form.setLeaveTypes(holidayBookingService.getLeaveTypes());
     
      form.setEditMode(true);
    }
    return "success";
  }

  public boolean isInputError()
  {
    return inputError;
  }

  public void setInputError(boolean inputError)
  {
    this.inputError = inputError;
  }

  @InjectRequestParameter
  public void setHolidayBookingId(Long holidayBookingId)
  {
    this.holidayBookingId = holidayBookingId;
  }

  @InjectSpringBean(name = "holidayBookingService")
  public void setHolidayBookingService(HolidayBookingService holidayBookingService)
  {
    this.holidayBookingService = holidayBookingService;
  }

  @InjectActionForm
  public void setForm(HolidayBookingForm form)
  {
    this.form = form;
  }

}
TOP

Related Classes of org.strecks.holidaybooking.web.strecks.action.EditBookingAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.