Package com.tubeonfire.entity

Examples of com.tubeonfire.entity.Feedback


  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    try {
      Feedback obj = new Feedback();
      TreeMap<String, String> check = new TreeMap<String, String>();
      String name = req.getParameter("name");
      String email = req.getParameter("email");
      String title = req.getParameter("title");
      String message = req.getParameter("message");

      // check name.
      if (name == null || name.length() == 0) {
        check.put("name", "Please enter your name.");
      } else {
        obj.setName(name);
      }

      // check mail
      if (email == null || email.length() == 0) {
        check.put("email", "Please enter your email.");
      } else {
        Pattern pattern = Pattern.compile(".+@.+\\.[a-z]+");
        Matcher m = pattern.matcher(email);
        boolean matchFound = m.matches();
        if (!matchFound) {
          check.put("email", "Please enter exactly email.");
        } else {
          obj.setEmail(email);
        }
      }

      // check title.
      if (title == null || title.length() == 0) {
        check.put("title", "Please enter message title.");
      } else {
        obj.setTitle(title);
      }

      // check message.
      if (message == null || message.length() == 0) {
        check.put("message", "Please enter message content.");
      } else {
        obj.setMessage(message);
      }

      // check cap.cha
      String remoteAddr = req.getRemoteAddr();
      ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
      reCaptcha.setPrivateKey("6LfUNtESAAAAANSiC1e3dD974bMUFY21S5QANakS");
      String challenge = req.getParameter("recaptcha_challenge_field");
      String uresponse = req.getParameter("recaptcha_response_field");
      ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(
          remoteAddr, challenge, uresponse);

      if (!reCaptchaResponse.isValid()) {
        check.put("capcha", "Please enter exactly what you see.");
      }
      if (check.size() > 0) {
        req.setAttribute("feedback", obj);
        req.setAttribute("check", check);
      } else {
        obj.setStatus(1);
        obj.setId(IdUniqueHelper.getId());
        FeedbackModel.insert(obj);
        FeedbackModel.clearModelCache();
        req.setAttribute("success",
            "Your feedback has been sent, we'll reply as soon as possible.");
      }
View Full Code Here


  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException, ServletException {
    try {
      HttpSession session = req.getSession();
      String id = req.getParameter("id");
      Feedback obj = FeedbackModel.getById(id);
      if (obj != null) {
        obj.setStatus(2);
        FeedbackModel.insert(obj);
        FeedbackModel.clearModelCache();
        req.setAttribute("obj", obj);
        req.getRequestDispatcher("/admin/view_feedback.jsp").forward(
            req, resp);
View Full Code Here

      throws IOException {
    String action = request.getParameter("action");
    if (action != null && action.equals("delete")) {
      try {
        String id = request.getParameter("id");
        Feedback obj = FeedbackModel.getById(id);
        if (obj != null) {
          FeedbackModel.delete(obj);
          FeedbackModel.clearModelCache();
          response.getWriter().print("");
        } else {
          response.getWriter()
              .print("Action fails ! Feedback's not exits or has been deleted !");
        }
      } catch (Exception e) {
        response.getWriter().print("Action fails ! Please try again !");
      }

    } else if (action != null && action.equals("delete-all")) {
      try {
        String strIds = (String) request.getParameter("ids");
        String[] ids = strIds.split(",");
        for (int i = 0; i < ids.length; i++) {
          if (!ids[i].isEmpty()) {
            Feedback obj = FeedbackModel.getById(ids[i]);
            if (obj != null) {
              FeedbackModel.delete(obj);             
            }           
          }
        }
View Full Code Here

  @SuppressWarnings("unchecked")
  public static Feedback getById(String id) {
    try {
      init();
      Feedback obj = new Feedback();
      String prefix = cachePrefix + "id_" + id;
      if (cache != null && cache.containsKey(prefix)) {
        obj = (Feedback) cache.get(prefix);
      } else {
        try {
View Full Code Here

TOP

Related Classes of com.tubeonfire.entity.Feedback

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.