package com.vst.webapp.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.beanutils.BeanUtils;
import com.vst.Constants;
import com.vst.model.Answer;
import com.vst.service.AnswerManager;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class AnswerController implements Controller {
private final Log log = LogFactory.getLog(AnswerController.class);
private AnswerManager answerManager = null;
public void setAnswerManager(AnswerManager answerManager) {
this.answerManager = answerManager;
}
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'handleRequest' method...");
}
Answer answer = new Answer();
// populate object with request parameters
BeanUtils.populate(answer, request.getParameterMap());
List answers = answerManager.getAnswers(answer);
return new ModelAndView("answerList", Constants.ANSWER_LIST, answers);
}
}