package commands;

import java.io.IOException;
import java.util.ArrayList;

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

import business.Professor;
import dao.FacadeDAO;
import dao.ProfessorDAO;

public class ProfessorPreenche extends AbstractCommand {

	ProfessorDAO professorDao = null;

	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, HttpServlet servlet) {
		ArrayList<Professor> professores = new ArrayList<Professor>();
		String id = request.getParameter("id");
		professorDao = FacadeDAO.getInstance(servlet).getProfessorDAO();
		Professor professor = professorDao.leProfessor(Integer.parseInt(id));
		professores.add(professor);
		request.setAttribute("professores", professores);

		RequestDispatcher rd = request
				.getRequestDispatcher("professorAlterar.jsp");
		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
