public void update(HttpServletRequest request, HttpServletResponse response) throws Exception { Province province = new Province(db); bindForm(province); province = province.update(); if (province != null) { request.setAttribute("province", province); formHandler.setFormMessage("Update Completed"); } else { formHandler.setFormMessage("Update Failed"); } forward("?page=/web/provinceEdit.jsp"); }
public void create(HttpServletRequest request, HttpServletResponse response) throws Exception { Province province = new Province(db); bindForm(province); province = province.create(); if (province != null) formHandler.setFormMessage( "Create Completed ,view <a href='process2?action=Province&cmd=view&id=" + province.getId() + "' target='_blank'>new Record</a>"); else formHandler.setFormMessage("Create Not Complete"); redirect("process2?action=Province&cmd=add"); }
// update public void edit(HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id"); if (id != null && !id.trim().equals("")) { Province province = new Province(db); province = province.findByPk(new Long(id)); if (province != null) { request.setAttribute("province", province); } else { formHandler.setFormMessage("Error : Not Found with id " + id); } } forward("?page=/web/provinceEdit.jsp"); }
// delete public void delete(HttpServletRequest request, HttpServletResponse response) throws Exception { String[] ids = request.getParameterValues("id"); if (ids != null && ids.length > 0) { Province province = new Province(db); List<Long> idList = new ArrayList<Long>(); for (int i = 0; i < ids.length; i++) idList.add(new Long(ids[i])); int deleteRow = province.deleteByPks(idList); formHandler.setFormMessage(" Delete " + deleteRow + " Row Completed "); } else { formHandler.setFormMessage("Plese Select At Least One For Delete"); } redirect("process2?action=Province&cmd=list"); }
// list public void list(HttpServletRequest request, HttpServletResponse response) throws Exception { Province province = new Province(db); // pageUtil.setPageSize(15); Integer totalRow = province.countAll(); // set TotalRow pageUtil.setTotalRow(totalRow); List<Province> provinces = province.findAll(pageUtil); // for data to display request.setAttribute("provinces", provinces); // for screen to show forward("?page=/web/provinceList.jsp"); }