public String onDelete() { try { Session session = getSession(); Long id = 0l; if (role.getId() > 0) { id = role.getId(); } else if (getRequest().getParameter("id") != null) { id = Long.parseLong(getRequest().getParameter("id")); } if (id != null && id > 0) { Roles temp = new Roles(); temp = (Roles) session.get(Roles.class, id); session.delete(temp); session.flush(); } jsonDataGrid.setLabel("SUCCESS"); jsonDataGrid.setCustomInfo("Delete Thành Công!"); if (getRequest().getParameter("id") == null) { role = new Roles(); onSearch(); } } catch (Exception ex) { jsonDataGrid.setLabel("ERROR"); jsonDataGrid.setCustomInfo(ex.getMessage()); } return "jsonDataGrid"; }
public String onUpdate() { try { Session session = getSession(); Long id = role.getId(); if (id != null && id > 0) { Roles temp = new Roles(); temp = (Roles) session.get(Roles.class, id); temp.setValue(role.getValue()); temp.setName(role.getName()); if (isactive != null) { temp.setIsactive("Y"); } else { temp.setIsactive("N"); } session.update(temp); session.flush(); } jsonDataGrid.setLabel("SUCCESS"); jsonDataGrid.setCustomInfo("Update Thành Công!"); onSearch(); } catch (Exception ex) { jsonDataGrid.setLabel("ERROR"); jsonDataGrid.setCustomInfo(ex.getMessage()); } return "jsonDataGrid"; }