@RequestMapping("my_view_articles") public ModelAndView getMyArticles(HttpSession session) { ModelAndView mv = new ModelAndView("my_view_articles"); Integer userId = (Integer) session.getAttribute("userId"); if (service.getMyArticles(userId) == null) { return mv; } else { mv.addObject("my_lst", service.getMyArticles(userId)); } return mv; }
@RequestMapping("edit") public ModelAndView edit( @RequestParam("tit") String tit, @RequestParam("cont") String cont, @RequestParam("desc") String desc, @RequestParam("articleId") Integer articleId) { ModelAndView mv = new ModelAndView("my_view_articles"); Article article = service.getArticle(articleId); article.setContent(cont); article.setTitle(tit); article.setDescription(desc); service.updateArticle(article); return mv; }
@RequestMapping("editform") public ModelAndView editform(@RequestParam("articleId") Integer articleId) { ModelAndView mv = new ModelAndView("editform"); mv.addObject("article", service.getArticle(articleId)); return mv; }
@RequestMapping("save") public ModelAndView save( @RequestParam("tit") String tit, @RequestParam("cont") String cont, @RequestParam("desc") String desc, HttpSession session) { ModelAndView mv = new ModelAndView("my_view_articles"); Integer userId = (Integer) session.getAttribute("userId"); User user = service.getUser(userId); log.log(Level.INFO, "User:", user.getName()); Article article = new Article(tit, desc, cont, user); service.saveArticle(article); return mv; }
@RequestMapping("my_view_article") public ModelAndView getMyArticle(@RequestParam("id") Integer id) { ModelAndView mv = new ModelAndView("my_view_article"); mv.addObject("article", service.getArticle(id)); return mv; }