/** 修改版面信息页面 */ public ActionForward editUI( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ForumForm forumForm = (ForumForm) form; Forum f = forumService.getForum(forumForm.getId()); // 第一次到修改页面时才需要准备数据,出错后转发过来的应显示上次的错误输入 if (forumForm.getCategoryId() == 0) { forumForm.setName(f.getName()); forumForm.setDescription(f.getDescription()); forumForm.setCategoryId(f.getCategory().getId()); } setCategoriesInRequestScope(request); return mapping.findForward("save"); }
/** 修改版面信息 */ public ActionForward edit( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (validateFailed(form, mapping, request)) { // validate form bean return editUI(mapping, form, request, response); } ForumForm forumForm = (ForumForm) form; Forum forum = forumService.getForum(forumForm.getId()); Category category = categoryService.getCategory(forumForm.getCategoryId()); forum.setName(forumForm.getName()); forum.setDescription(forumForm.getDescription()); forum.setCategory(category); forumService.updateForum(forum); return mapping.findForward("showCategories"); }