public String addPage() { id = (Long) request.getSession().getAttribute("SESSION_CONTENT_ADD_ID"); if (id == null) { content = new Content(); } else { content = this.contentManager.get(id); } content.setClick(0); content.setTop(0); content.setCreatedate(new Date()); content.setState(2); this.contentManager.save(content); request.getSession().setAttribute("SESSION_CONTENT_ADD_ID", content.getId()); List<ContentType> types = this.typeManager.findList(); request.setAttribute("types", types); return "addPage"; }
public String editPage() { content = this.contentManager.get(id); List photos = content.getPhotos(); request.setAttribute("photos", photos); request.setAttribute("photos_size", photos.size()); List<ContentType> types = this.typeManager.findList(); request.setAttribute("types", types); return "editPage"; }
public String save() { if (content.getType() != null && content.getType().getId() == null) { content.setType(null); } if (content.getType() != null) { ContentType type = this.typeManager.get(content.getType().getId()); content.setType(type); content.setTypename(type.getName()); } if (id == null) { content.setPubdate(new Date()); content.setCreatedate(content.getPubdate()); } this.contentManager.save(content); request.getSession().removeAttribute("SESSION_CONTENT_ADD_ID"); request.setAttribute(GLB_MESSAGE, "保存成功!"); request.setAttribute( CommonConstants.GLB_RETURN_URL, request.getContextPath() + "/admin/content!list.action"); return GLB_MESSAGE_PAGE; }