/** * Contains Submit Logic * * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("CollegeCtl Method doPost Started"); String op = DataUtility.getString(request.getParameter("operation")); // get model CollegeModel model = (CollegeModel) populateModel(request); long id = model.getId(); if (OP_SAVE.equalsIgnoreCase(op)) { try { if (id > 0) { model.update(); } else { long pk = model.add(); model.setId(pk); } ServletUtility.setModel(model, request); ServletUtility.setSuccessMessage("Data is successfully saved", request); } catch (ApplicationException e) { log.error(e); ServletUtility.handleException(e, request, response); return; } catch (DuplicateRecordException e) { log.error(e); ServletUtility.setModel(model, request); ServletUtility.setErrorMessage("College name allready exists !", request); ServletUtility.forwardView(ORSView.COLLEGE_VIEW, request, response); } } else if (OP_DELETE.equalsIgnoreCase(op)) { try { model.delete(); ServletUtility.redirect(ORSView.COLLEGE_LIST_CTL, request, response); return; } catch (ApplicationException e) { log.error(e); ServletUtility.handleException(e, request, response); return; } } else { if (id > 0 || op != null) { CollegeModel model1; try { model1 = model.findByPK(id); ServletUtility.setModel(model1, request); } catch (ApplicationException e) { ServletUtility.handleException(e, request, response); return; } } } ServletUtility.forwardView(ORSView.COLLEGE_VIEW, request, response); log.debug("CollegeCtl Method doPost Ended"); }
/** Contains Display Logic */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); UserModel sessionModel = (UserModel) session.getAttribute("user"); Long id = sessionModel.getCollegeId(); Long roleId = sessionModel.getRoleId(); if (id == 0) { id = DataUtility.getLong(request.getParameter("id")); } CollegeModel model = new CollegeModel(); System.out.println("org12" + UserFilterManager.getOrganizationId(request)); model.setOrganizationId(UserFilterManager.getOrganizationId(request)); if (id > 0) { try { model = model.findByPK(id); ServletUtility.setModel(model, request); } catch (ApplicationException e) { ServletUtility.handleException(e, request, response); return; } } ServletUtility.setModel(model, request); ServletUtility.forwardView(ORSView.COLLEGE_VIEW, request, response); }
/** Contains Display Logic */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Long id = DataUtility.getLong(request.getParameter("id")); UserModel model = new UserModel(); if (id > 0) { try { model = model.findByPK(id); ServletUtility.setModel(model, request); } catch (ApplicationException e) { ServletUtility.handleException(e, request, response); return; } } ServletUtility.forwardView(ORSView.USER_VIEW, request, response); }