private String getProjectsListHTML(String column, String order) { // System.out.println("AddProjectServlet.getPrjectsHTML filter = " + filter.toString()); String html = parameterDAO.getProjectsListHTML(column, order, baseurl, filter); System.out.println("Filter FINISHED as = " + filter.toFilterString()); // System.out.println("Filter Training FINISHED as, ParameterDAO.(Training) = " + // ParameterDAO.parse(filter.getTraining())); // System.out.println("Filter Capability Area(s) FINISHED as = " + filter.getCapabilityAreas()); // filter=new ProjectBean(); return html; }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("AddProjectServlet.doPost Entered..."); init(response); PrintWriter out = response.getWriter(); dataSource = (DataSource) request.getSession().getServletContext().getAttribute("DBCPool"); baseurl = config.getServletContext().getInitParameter("baseurl"); // filesystem web-root parameterDAO.setDataSource(dataSource); pb.setParameterDAO(parameterDAO); filter.setParameterDAO(parameterDAO); System.out.println("AddProjectServlet.doPost done inits pb.set, filter.set..."); if (ParameterDAO.parse(request.getParameter("clearmsgs"))) { msg = new StringBuffer(); } String[] deleted = request.getParameterValues("delete"); String addnew = request.getParameter("addnew"); String updated = request.getParameter("updated"); String undelete = request.getParameter("undelete"); String searchbyx = request.getParameter("searchbyx"); filter.setSearchString(StringUtils.trimToEmpty(request.getParameter("search"))); String sortby = StringUtils.trimToEmpty(request.getParameter("sortby")); String order = "DESC"; if (!ParameterDAO.parse(request.getParameter("order"))) order = "ASC"; // if coming from addContacts, success or failure... if (ParameterDAO.parse(request.getAttribute("addcontacts")) || ParameterDAO.parse(request.getAttribute("addagencies")) || ParameterDAO.parse(request.getAttribute("uploadedfile"))) { msg.append(StringUtils.trimToEmpty((String) request.getAttribute("msg"))); } else if (StringUtils.isNotBlank(filter.getSearchString())) { // triggers the simple search exclusive of any other action (safe from delete, by preceding in // if-then ) // do absolutely nothing the search field will be populated just fine as expected. Later, may // be add X number of projects } else if (deleted == null) { // System.out.println("AddProjectServlet.doPost Entered else if deleted == null"); // coming from index.jsp if (ParameterDAO.parse(updated)) { addProject(request, response, true); } else if (ParameterDAO.parse(undelete)) { parameterDAO.unDeleteAllProjects(); } else if (ParameterDAO.parse(addnew)) { addProject(request, response, false); } else if (ParameterDAO.parse(searchbyx)) { // we are just setting filter setProjectBean(request); filter = pb; System.out.println("Filter STARTS LIFE as = " + filter.toFilterString()); // System.out.println("Filter Training INIT parsed as = " + // ParameterDAO.parse(filter.getTraining())); // System.out.println("Filter Capability Area(s) INIT as = " + filter.getCapabilityAreas()); msg.append("Advanced Search Parameters = "); msg.append( "<div style=\"font-family: 'trebuchet ms', sans-serif; font-size: 9px; font-style: italic; text-transform: lowercase; display: inline; \">"); msg.append(filter.toFilterString()); msg.append("</div><br />"); } } else if (deleted.length == 0) { // came from projects list but nothing to do...later when table cells are editable, we may @TO // DO capture all edits/updates here } else { parameterDAO.deleteProject(deleted); int count = 0; for (int i = 0; i < deleted.length; i++) { count++; if (count == 1) { msg.append("Project(s) <strong><span style=\"background-color: #FFFF00\">"); } else { msg.append(", <strong><span style=\"background-color: #FFFF00\">"); } msg.append( StringEscapeUtils.escapeHtml( parameterDAO.getJustOneProject(deleted[i]).getProjectname())); msg.append("</span></strong>"); } if (count > 0) msg.append(" D E L E T E D<BR />"); } ///////////////////////////////////////////// // Draw the projects list table // out.println(getHeader()); out.println(getMessageTable(msg)); // System.out.println("AddProjectServlet.doPost drawing projects table " + filter.toString()); if (StringUtils.isBlank(sortby)) { out.println(getProjectsListHTML()); } else if (StringUtils.equalsIgnoreCase(sortby, "code")) { out.println(getProjectsListHTML("code", order)); } else if (StringUtils.equalsIgnoreCase(sortby, "name")) { out.println(getProjectsListHTML("nametitle", order)); } else if (StringUtils.equalsIgnoreCase(sortby, "description")) { out.println(getProjectsListHTML("description", order)); } else if (StringUtils.equalsIgnoreCase(sortby, "status")) { out.println(getProjectsListHTML("status", order)); } else { out.println(getProjectsListHTML()); } out.println(getFooter()); filter = new ProjectBean(); // System.out.println("AddProjectServlet.doPost DONE"); }