示例#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) {
   Base base = baseService.findBase(id);
   baseService.deleteBase(base);
   uiModel.asMap().clear();
   uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
   uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
   return "redirect:/bases";
 }
示例#2
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("bases", baseService.findBaseEntries(firstResult, sizeNo));
     float nrOfPages = (float) baseService.countAllBases() / sizeNo;
     uiModel.addAttribute(
         "maxPages",
         (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
   } else {
     uiModel.addAttribute("bases", baseService.findAllBases());
   }
   return "bases/list";
 }
示例#3
0
 @RequestMapping(method = RequestMethod.PUT, produces = "text/html")
 public String update(
     @Valid Base base,
     BindingResult bindingResult,
     Model uiModel,
     HttpServletRequest httpServletRequest) {
   if (bindingResult.hasErrors()) {
     populateEditForm(uiModel, base);
     return "bases/update";
   }
   uiModel.asMap().clear();
   baseService.updateBase(base);
   return "redirect:/bases/" + encodeUrlPathSegment(base.getId().toString(), httpServletRequest);
 }
示例#4
0
 @RequestMapping(value = "/{id}", params = "form", produces = "text/html")
 public String updateForm(@PathVariable("id") Long id, Model uiModel) {
   populateEditForm(uiModel, baseService.findBase(id));
   return "bases/update";
 }
示例#5
0
 @RequestMapping(value = "/{id}", produces = "text/html")
 public String show(@PathVariable("id") Long id, Model uiModel) {
   uiModel.addAttribute("base", baseService.findBase(id));
   uiModel.addAttribute("itemId", id);
   return "bases/show";
 }