/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/
package it.hotel.controller.booking;
import it.hotel.controller.booking.DTO.VacancyDTO;
import it.hotel.controller.hotel.HotelSimpleFormController;
import it.hotel.model.booking.manager.IBookingManager;
import it.hotel.model.typology.manager.ITypologyManager;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
/**
*
*
*/
public class BookingVacancyController extends HotelSimpleFormController {
private IBookingManager bookingManager;
private ITypologyManager typologyManager;
protected Object formBackingObject (HttpServletRequest request) throws Exception {
VacancyDTO vacancyDTOForm = (VacancyDTO)super.formBackingObject(request);
return vacancyDTOForm;
}
/**
* @throws
* @return
*/
protected Map referenceData (HttpServletRequest req) throws Exception{
Map map = new HashMap();
map.put("typologies", typologyManager.getAll());
return map;
}
/**
* @throws
* @return
*/
@Override
protected ModelAndView onSubmit(HttpServletRequest req, HttpServletResponse res, Object command, BindException errors) throws Exception {
VacancyDTO dto = (VacancyDTO) command;
req.getSession().removeAttribute("backofficeDTO");
req.getSession().setAttribute("backofficeDTO", dto);
return new ModelAndView("redirect:/Booking/new.htm");
};
@Resource(name = "bookingManager")
public void setBookingManager(IBookingManager bookingManager) {
this.bookingManager = bookingManager;
}
@Resource(name = "typologyManager")
public void setTypologyManager(ITypologyManager typologyManager) {
this.typologyManager = typologyManager;
}
}