context.put("form", form);
return renderToResponse("src/main/webapp/templates/detail.html", context);
}
Long choice = (Long)form.getCleanedData().get("choice");
Choice selected_choice = modelFactory.dao(Choice.class).get(choice);
if (selected_choice == null) {
Map<String, Object> context = new HashMap<String, Object>();
context.put("poll", p);
context.put("error_message", "You didn't select a valid choice");
context.put("form", form);
return renderToResponse("src/main/webapp/templates/detail.html", context);
} else {
int votes = selected_choice.getVotes() == null ? 0 : selected_choice.getVotes().intValue();
selected_choice.setVotes(votes + 1);
// due to the way hibernate works this will automatically save when the middleware commits
return new HttpResponseRedirect("/polls/" + poll_id + "/results/");
}
} catch (DaoException e) {
throw new HttpException(e);