Пример #1
0
  /**
   * Delete.
   *
   * @param id the id
   * @param model the model
   * @param redirectAttrs the redirect attrs
   * @param locale the locale
   * @return the string
   */
  @RequestMapping("/delete/{id}")
  public String delete(
      @PathVariable Long id, Model model, RedirectAttributes redirectAttrs, Locale locale) {
    Item item = itemService.get(id);
    if (item != null) {
      itemService.delete(id);

      redirectAttrs.addFlashAttribute(
          "message",
          MessageFormat.format(
              messageSource.getMessage("item.deleted", null, locale), item.getName()));

      return "redirect:/item/list";
    }
    model.addAttribute(
        "message",
        MessageFormat.format(messageSource.getMessage("item.deleted.failed", null, locale), id));
    return "/item/form";
  }
Пример #2
0
 /**
  * Update.
  *
  * @param id the id
  * @param model the model
  * @return the string
  */
 @RequestMapping("/edit/{id}")
 public String update(@PathVariable Long id, Model model) {
   model.addAttribute("item", itemService.get(id));
   model.addAttribute("readonly", false);
   return "/item/form";
 }
Пример #3
0
 /**
  * View.
  *
  * @param id the id
  * @param model the model
  * @return the string
  */
 @RequestMapping("/view/{id}")
 public String view(@PathVariable Long id, Model model) {
   model.addAttribute("item", itemService.get(id));
   model.addAttribute("readonly", true);
   return "/item/form";
 }