htmlResult.ensureCapacity(128);
boolean allowViewResults = (Boolean) request.getAttribute("allowViewResults");
boolean showVotes = (Boolean) request.getAttribute("showVotes");
PollsAjax.VoteAnswer result = new PollsAjax().new VoteAnswer();
boolean hasVoted = false;
if (pollsAPI.hasVoted(questionId)
|| (session.getAttribute(PollsQuestion.class.getName() + "."
+ questionId + "._voted") != null)) {
hasVoted = true;
}
if (!hasVoted) {
PollsQuestion question = pollsAPI.getQuestion(questionId);
List choices = pollsAPI.getChoices(questionId);
Iterator itr = choices.iterator();
htmlResult.append("<table class='poll-answer-table' id='answer" + questionId + "'>");
while (itr.hasNext()) {
PollsChoice choice = (PollsChoice) itr.next();
htmlResult.append("<tr><td class='poll-radio'>");
htmlResult
.append("<input type='radio' name='question" + questionId + "' id='choice-" + choice.getChoiceId() + "' value='"
+ choice.getChoiceId() + "'/>");
htmlResult.append("</td><td class='poll-label'>");
htmlResult.append("<label for='choice-"+ choice.getChoiceId() +"'>" + choice.getDescription() + "</label>");
htmlResult.append("</td></tr>");
}
htmlResult.append("<tr><td colspan='2' class='poll-buttons'>");
htmlResult.append("<input type=button onclick=\"vote('" + questionId + "');\" value='"+globalVars.get("Vote")+"' class='poll-vote'>");
htmlResult.append("</td></tr>");
if (allowViewResults) {
htmlResult.append("<tr><td colspan='2' class='poll-view-results'>");
htmlResult.append("<a href='#' onclick=\"showResults('" + questionId + "');\">"+globalVars.get("View-Results")+"</a>");
htmlResult.append("</td></tr>");
}
htmlResult.append("</table>");
result = new PollsAjax().new VoteAnswer(questionId,htmlResult.toString());
} else {
result = displayPollResults(questionId, showVotes);