/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/
package it.hotel.controller.customer;
import it.hotel.controller.hotel.HotelSimpleFormController;
import it.hotel.model.customer.Customer;
import it.hotel.model.customer.manager.ICustomerManager;
import it.hotel.system.SystemUtils;
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 CustomerSearchController extends HotelSimpleFormController {
private ICustomerManager customerManager;
/**
* @throws
* @return
*/
@Override
protected Object formBackingObject(HttpServletRequest request)
throws Exception {
Customer customer = (Customer) super.formBackingObject(request);;
SystemUtils.print("customer", customer.getName());
String name = request.getParameter("name");
String surname = request.getParameter("surname");
if(!"".equals(name)) customer.setName(name);
if(!"".equals(surname)) customer.setSurname(surname);
return customer;
}
/**
* @throws
* @return
*/
@Override
protected ModelAndView processFormSubmission(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
Customer customer = (Customer) formBackingObject(request);
request.setAttribute("elements", customerManager.searchCustomer(customer));
return super.processFormSubmission(request, response, command, errors);
}
@Resource(name = "customerManager")
public void setCustomerManager(ICustomerManager customerManager){
this.customerManager=customerManager;
}
}