package br.com.senacagil.springmvc.controllers;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import br.com.senacagil.springmvc.business.Professor;
import br.com.senacagil.springmvc.dao.ProfessorDAO;

public class ProfessorListarController implements Controller {

	private ProfessorDAO professorDao = null;
	 
	public void setProfessorDao(ProfessorDAO professorDao) {
		this.professorDao = professorDao;
	}

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
  
		List<Professor> professores = professorDao.listarProfessores();

		ModelAndView modelAndView = new ModelAndView("professorListar", "lista_professores", professores);
		//modelAndView.addObject("message", message);
 
		return modelAndView;
	}
}
