public String addChat() { System.out.println("addchat"); Chat cht = new Chat(); ChatDAO dao = new ChatDAO(); if (chat.getElchName() == null || chat.getElchName().equals("")) { System.out.println("1"); ActionContext.getContext().put("error", "讨论名称不能为空"); return turnAddChat(); } cht.setElchId(UUID.randomUUID().toString().replaceAll("-", "")); cht.setElchName(chat.getElchName()); cht.setElchReverse1(chat.getElchReverse1()); cht.setElchReverse2("0"); cht.setElchTime(new Date()); cht.setElcourseId(coursedata.getElcourseId()); try { dao.getSession().clear(); dao.beginThransaction(); dao.createChat(cht); dao.commitThransaction(); } catch (Exception e) { // TODO: handle exception dao.rollbackThransaction(); } return turnChatGrid(); }
public String updateChat() { System.out.println("updatechat"); ChatDAO dao = new ChatDAO(); if (chat.getElchName() == null || chat.getElchName().equals("")) { System.out.println("1"); ActionContext.getContext().put("error", "讨论名称不能为空"); return turnUpdateChat(); } try { dao.getSession().clear(); dao.beginThransaction(); dao.modifyChat(chat); dao.commitThransaction(); } catch (Exception e) { // TODO: handle exception dao.rollbackThransaction(); } return turnChatGrid(); }