示例#1
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }
示例#2
0
    public void execute(Event<UIVoteQuestion> event) throws Exception {
      UIVoteQuestion voteQuestion = event.getSource();
      int number = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
      String currentUser = FAQUtils.getCurrentUser();
      List<String> listUsers = new ArrayList<String>();

      if (voteQuestion.question_.getUsersVote() != null) {
        listUsers.addAll(Arrays.asList(voteQuestion.question_.getUsersVote()));
      }
      long totalVote = listUsers.size();
      double markVote =
          (voteQuestion.question_.getMarkVote() * totalVote + number) / (totalVote + 1);

      listUsers.add(currentUser + "/" + number);
      voteQuestion.question_.setMarkVote(markVote);
      voteQuestion.question_.setUsersVote(listUsers.toArray(new String[] {}));
      FAQService faqService_ =
          (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
      FAQUtils.getEmailSetting(voteQuestion.faqSetting_, false, false);
      faqService_.saveQuestion(voteQuestion.question_, false, voteQuestion.faqSetting_);
      UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
      UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
      UIQuestions questions =
          portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
      // questions.setIsNotChangeLanguage() ;
      event.getRequestContext().addUIComponentToUpdateByAjax(questions);
      popupAction.deActivate();
      event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
    }
示例#3
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   double markVote = Double.parseDouble(event.getRequestContext().getRequestParameter(OBJECTID));
   FAQService faqService_ =
       (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
   Answer answer = null;
   if (voteQuestion.language_ != null
       && voteQuestion.language_.trim().length() > 0
       && !voteQuestion.language_.equals(voteQuestion.question_.getLanguage())) {
     answer =
         faqService_.getAnswerById(
             voteQuestion.question_.getPath(), voteQuestion.answerId_, voteQuestion.language_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, voteQuestion.language_);
   } else {
     answer =
         faqService_.getAnswerById(voteQuestion.question_.getPath(), voteQuestion.answerId_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, false);
   }
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   UIQuestions questions =
       portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
   // questions.setIsNotChangeLanguage() ;
   event.getRequestContext().addUIComponentToUpdateByAjax(questions);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }