@Override
 public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
   Contexto oContexto = (Contexto) request.getAttribute("contexto");
   oContexto.setVista("jsp/alumno/list.jsp");
   try {
     AlumnoDao oAlumnoDao = new AlumnoDao(oContexto.getEnumTipoConexion());
     Integer intPages =
         oAlumnoDao.getPages(oContexto.getNrpp(), oContexto.getHmFilter(), oContexto.getHmOrder());
     if (oContexto.getPage() >= intPages) {
       oContexto.setPage(intPages);
     }
     ArrayList<AlumnoBean> listado =
         (ArrayList<AlumnoBean>)
             oAlumnoDao.getPage(
                 oContexto.getNrpp(),
                 oContexto.getPage(),
                 oContexto.getHmFilter(),
                 oContexto.getHmOrder());
     ArrayList<String> vecindad =
         (ArrayList<String>)
             oAlumnoDao.getNeighborhood(
                 "<a href=\"Controller?class=alumno&method=list&rpp="
                     + oContexto.getNrpp()
                     + "&page=",
                 oContexto.getPage(),
                 intPages,
                 2);
     ArrayList<Object> a = new ArrayList<>();
     a.add(listado);
     a.add(vecindad);
     return a;
   } catch (Exception e) {
     throw new ServletException("AlumnoList1: View Error: " + e.getMessage());
   }
 }
Esempio n. 2
0
  @Override
  public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {
      AlumnoDao oAlumnoDAO = new AlumnoDao(Conexion.getConection());
      AlumnoBean oAlumno = new AlumnoBean();
      oAlumno.setId(Integer.parseInt(request.getParameter("id")));
      Map<String, String> data = new HashMap<>();
      if (oAlumno != null) {
        oAlumnoDAO.remove(oAlumno);
        data.put("status", "200");
        data.put("message", "se ha eliminado el registro con id=" + oAlumno.getId());
      } else {
        data.put("status", "error");
        data.put("message", "error");
      }
      Gson gson = new Gson();
      String resultado = gson.toJson(data);
      return resultado;
    } catch (Exception e) {
      throw new ServletException("AlumnoRemoveJson: View Error: " + e.getMessage());
    }
  }
 @Override
 public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
   String data;
   try {
     ArrayList<FilterBean> alFilter = new ArrayList<>();
     if (request.getParameter("filter") != null) {
       if (request.getParameter("filteroperator") != null) {
         if (request.getParameter("filtervalue") != null) {
           FilterBean oFilterBean = new FilterBean();
           oFilterBean.setFilter(request.getParameter("filter"));
           oFilterBean.setFilterOperator(request.getParameter("filteroperator"));
           oFilterBean.setFilterValue(request.getParameter("filtervalue"));
           oFilterBean.setFilterOrigin("user");
           alFilter.add(oFilterBean);
         }
       }
     }
     if (request.getParameter("systemfilter") != null) {
       if (request.getParameter("systemfilteroperator") != null) {
         if (request.getParameter("systemfiltervalue") != null) {
           FilterBean oFilterBean = new FilterBean();
           oFilterBean.setFilter(request.getParameter("systemfilter"));
           oFilterBean.setFilterOperator(request.getParameter("systemfilteroperator"));
           oFilterBean.setFilterValue(request.getParameter("systemfiltervalue"));
           oFilterBean.setFilterOrigin("system");
           alFilter.add(oFilterBean);
         }
       }
     }
     AlumnoDao oAlumnoDAO = new AlumnoDao(Conexion.getConection());
     int pages = oAlumnoDAO.getCount(alFilter);
     data = "{\"data\":\"" + Integer.toString(pages) + "\"}";
     return data;
   } catch (Exception e) {
     throw new ServletException("AlumnoGetregistersJson: View Error: " + e.getMessage());
   }
 }