package commands;

import java.io.IOException;

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

import spring.Context;

import business.Turma;
import dao.*;

public class TurmaPrepararFormAlteracao extends AbstractCommand {

	private TurmaDAO turmaDAO = DAOFactory.getInstance().getTurmaDAO();

	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, Context context) {
		String id = request.getParameter("id");
		Turma turma = turmaDAO.leTurma(Long.parseLong(id));

		request.setAttribute("turma", turma);

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

}
