/** 编辑实体 action的方法,首先获取entity的信息,返回到编辑页面 */ public String editKbDisease() { log.info(logprefix + "editKbDisease"); try { // 实体的id可以为0 if (kbDisease.getId() != null && kbDisease.getId() >= 0) { KbDisease temKbDisease = kbDiseaseService.selectKbDiseaseById(kbDisease.getId()); if (temKbDisease != null) { BeanUtils.copyProperties(kbDiseaseModel, temKbDisease); // actionMsg = getText("selectKbDiseaseByIdSuccess"); return SUCCESS; } } return "PageNotExist"; } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); log.error("类KbDiseaseAction的方法:selectKbDiseaseById错误" + e); } return "error"; }
/** 编辑实体Full action的方法,首先获取entityfull的信息,返回到编辑页面 */ public String editKbDiseaseFull() { log.info(logprefix + "viewKbDisease"); try { if (kbDisease.getId() != null && kbDisease.getId() > 0) { KbDiseaseFull temKbDiseaseFull = kbDiseaseService.selectKbDiseaseFullById(kbDisease.getId()); BeanUtils.copyProperties(kbDiseaseFull, temKbDiseaseFull); actionMsg = getText("selectKbDiseaseByIdSuccess"); } else { actionMsg = getText("selectKbDiseaseByIdFail"); System.out.println(actionMsg); } return SUCCESS; } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); log.error("类KbDiseaseAction的方法:selectKbDiseaseFullById错误" + e); } return "error"; }
/** * view KbDiseaseFull need give parmeter id get id from modle, * * @return */ public String viewKbDiseaseFull() { try { int getId = kbDisease.getId(); log.info(this.logprefix + ";id=" + getId); if (getId < 0) { log.error("error,id小于0不规范"); return "error"; } KbDiseaseFull temKbDiseaseFull = kbDiseaseService.selectKbDiseaseFullById(getId); if (temKbDiseaseFull != null) { BeanUtils.copyProperties(kbDiseaseFull, temKbDiseaseFull); return SUCCESS; } else { log.error("error,查询实体不存在。"); return "Error"; } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return "Error"; }
// ajax 修改 public String updateKbDiseaseAjax() { log.info(logprefix + "updateKbDiseaseAjax,id=" + kbDisease.getId()); ReturnJson returnJson = new ReturnJson(); try { if (kbDisease.getId() != null && kbDisease.getId() > 0) { KbDisease tempKbDisease = kbDiseaseService.selectKbDiseaseById(kbDisease.getId()); // 选择能更改的属性,与界面一致 tempKbDisease.setName(kbDisease.getName()); tempKbDisease.setDescription(kbDisease.getDescription()); tempKbDisease.setKeshiid(kbDisease.getKeshiid()); kbDiseaseService.updateKbDisease(tempKbDisease); returnJson.setFlag(1); returnJson.setReason("修改成功"); JSONObject jo = JSONObject.fromObject(returnJson); this.returnStr = jo.toString(); // actionMsg = getText("viewKbDiseaseSuccess"); return SUCCESS; } else { actionMsg = getText("viewKbDiseaseFail"); log.info(logprefix + "updateKbDiseaseAjax fail"); } } catch (Exception e) { e.printStackTrace(); log.error("类KbDiseaseAction的方法:viewKbDisease错误" + e); } returnJson.setFlag(0); JSONObject jo = JSONObject.fromObject(returnJson); this.returnStr = jo.toString(); return SUCCESS; }