@RequestMapping(value = {"/", "/listUsers"}) public String listUsers(Map<String, Object> map) { if (pagedListHolder == null) { pagedListHolder = new PagedListHolder(userService.listUsers(search)); pagedListHolder.setPage(0); pagedListHolder.setPageSize(3); } map.put("user", new User()); map.put("userList", pagedListHolder); map.put("search", search); return "/users/listUsers"; }
@RequestMapping(value = "/search") public String searchUsers(@RequestParam(required = false, defaultValue = "") String name) { search = name.trim(); pagedListHolder.setSource(userService.listUsers(search)); return "redirect:/users/listUsers"; }
@RequestMapping(value = "/delete/{userId}") public String deleteUser(@PathVariable Long userId) { userService.deleteUser(userId); pagedListHolder.setSource(userService.listUsers(search)); return "redirect:/users/listUsers"; }
@RequestMapping(value = "/get/{userId}") public String getUser(@PathVariable Long userId, Map<String, Object> map) { User user = userService.getUser(userId); map.put("user", user); return "/users/userForm"; }
@RequestMapping(value = "/save", method = RequestMethod.POST) public String saveUser(@ModelAttribute("user") User user, BindingResult result) { userService.saveUser(user); pagedListHolder.setSource(userService.listUsers(search)); return "redirect:/users/listUsers"; }