1 package org.objectweb.petals.demo.icare.web; 2 3 import java.util.Map ; 4 5 import javax.servlet.http.HttpServletRequest ; 6 7 import org.objectweb.petals.demo.icare.model.dto.CarSearchDto; 8 import org.objectweb.petals.demo.icare.service.CarService; 9 import org.springframework.ui.ModelMap; 10 import org.springframework.validation.Errors; 11 import org.springframework.web.servlet.mvc.SimpleFormController; 12 13 19 public class CarSearchFormController extends SimpleFormController { 20 21 private CarService carService; 22 23 public CarService getCarService() { 24 return carService; 25 } 26 27 public void setCarService(CarService carService) { 28 this.carService = carService; 29 } 30 31 protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { 32 return new ModelMap("categories", carService.getAllCategories()); 33 } 34 35 protected Object formBackingObject(HttpServletRequest request) throws Exception { 36 return new CarSearchDto(); 37 } 38 39 protected void doSubmitAction(Object managedResource) throws Exception { 40 CarSearchDto dto = (CarSearchDto) managedResource; 41 carService.getAvailableCars(dto); 42 } 43 44 } 45 | Popular Tags |