Package com.tubeonfire.ajax.admin

Source Code of com.tubeonfire.ajax.admin.ProcessFeedback

package com.tubeonfire.ajax.admin;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tubeonfire.entity.Feedback;
import com.tubeonfire.model.admin.FeedbackModel;

@SuppressWarnings("serial")
public class ProcessFeedback extends HttpServlet {
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      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);             
            }           
          }
        }
        FeedbackModel.clearModelCache();
        response.getWriter().print("");
      } catch (Exception e) {
        response.getWriter().print("Action fails ! Please try again !");
      }
    }
  }
}
TOP

Related Classes of com.tubeonfire.ajax.admin.ProcessFeedback

TOP
Copyright © 2018 www.massapi.com. 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.