コード例 #1
0
  @RequestMapping(value = "/admin/user/edit/{id}", method = RequestMethod.GET)
  public ModelAndView edit(@PathVariable int id) {

    User user = userService.findEntityById(id);

    ModelAndView modelAndView = new ModelAndView("admin/user/edit");
    modelAndView.addObject("command", user);

    return modelAndView;
  }
コード例 #2
0
  @RequestMapping(value = "/admin/user/show/{userId}", method = RequestMethod.GET)
  public String showUser(@PathVariable("userId") int userId, Model model) {

    User user = userService.findEntityById(userId);

    if (user != null) {
      model.addAttribute(user);
      return "admin/user/show";
    } else {
      return "redirect:/admin/user/list";
    }
  }
コード例 #3
0
  @RequestMapping(value = "/admin/user/delete/{id}")
  public String deleteUser(@PathVariable("id") int id, HttpSession session) {

    User user = userService.findEntityById(id);
    if (user != null) {
      try {
        userService.delete(user);
      } catch (RuntimeException re) {
        pageFrameworkService.setFlashMessage(session, re.getMessage());
        pageFrameworkService.setIsRedirect(session, Boolean.TRUE);
        return "redirect:/admin/user/show/" + id;
      }
    } else {
      pageFrameworkService.setFlashMessage(session, "No User with that id");
      pageFrameworkService.setIsRedirect(session, Boolean.TRUE);
    }
    return "redirect:/admin/user/list";
  }