package it.hotel.controller.photo;
import it.hotel.model.photo.Photo;
import it.hotel.model.structure.Structure;
import it.hotel.model.structure.manager.IStructureManager;
import java.util.Collection;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class PhotoController implements Controller{
IStructureManager structureManager;
public ModelAndView handleRequest(HttpServletRequest req,
HttpServletResponse resp) throws Exception {
String idString = req.getParameter("id");
Structure hotel=(Structure) structureManager.get(Integer.parseInt(idString));
Collection<Photo> photos = (Collection<Photo>)hotel.getGallery().getPhotos();
ModelAndView mv= new ModelAndView("photo","photos",photos) ;
return mv;
}
@Resource(name = "structureManager")
public void setStructureManager(IStructureManager structureManager) {
this.structureManager = structureManager;
}
public IStructureManager getStructureManager() {
return structureManager;
}
}