示例#1
0
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
 public String delete(
     @PathVariable("id") Long id,
     @RequestParam(value = "page", required = false) Integer page,
     @RequestParam(value = "size", required = false) Integer size,
     Model uiModel) {
   Team team = Team.findTeam(id);
   team.remove();
   uiModel.asMap().clear();
   uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
   uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
   return "redirect:/teams";
 }
示例#2
0
 @RequestMapping(method = RequestMethod.PUT, produces = "text/html")
 public String update(
     @Valid Team team,
     BindingResult bindingResult,
     Model uiModel,
     HttpServletRequest httpServletRequest) {
   if (bindingResult.hasErrors()) {
     populateEditForm(uiModel, team);
     return "teams/update";
   }
   uiModel.asMap().clear();
   team.merge();
   return "redirect:/teams/" + encodeUrlPathSegment(team.getId().toString(), httpServletRequest);
 }
示例#3
0
 @RequestMapping(produces = "text/html")
 public String list(
     @RequestParam(value = "page", required = false) Integer page,
     @RequestParam(value = "size", required = false) Integer size,
     Model uiModel) {
   if (page != null || size != null) {
     int sizeNo = size == null ? 10 : size.intValue();
     final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
     uiModel.addAttribute("teams", Team.findTeamEntries(firstResult, sizeNo));
     float nrOfPages = (float) Team.countTeams() / sizeNo;
     uiModel.addAttribute(
         "maxPages",
         (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
   } else {
     uiModel.addAttribute("teams", Team.findAllTeams());
   }
   return "teams/list";
 }
示例#4
0
 @RequestMapping(value = "/{id}", params = "form", produces = "text/html")
 public String updateForm(@PathVariable("id") Long id, Model uiModel) {
   populateEditForm(uiModel, Team.findTeam(id));
   return "teams/update";
 }
示例#5
0
 @RequestMapping(value = "/{id}", produces = "text/html")
 public String show(@PathVariable("id") Long id, Model uiModel) {
   uiModel.addAttribute("team", Team.findTeam(id));
   uiModel.addAttribute("itemId", id);
   return "teams/show";
 }