Package com.dotmarketing.cms.polls.ajax

Examples of com.dotmarketing.cms.polls.ajax.PollsAjax


    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);
View Full Code Here


      htmlResult.append("</td>");
    htmlResult.append("</tr>");
    htmlResult.append("</table>");
    htmlResult.append("</div>");

    return new PollsAjax().new VoteAnswer(questionId,htmlResult.toString());
  }
View Full Code Here

TOP

Related Classes of com.dotmarketing.cms.polls.ajax.PollsAjax

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.