Beispiel #1
0
  @RequestMapping(value = "/edit/row/{reportId}/{rowId}", method = POST)
  public String saveRow(
      @PathVariable Long reportId,
      @PathVariable Long rowId,
      @Valid @ModelAttribute(ROW) RowSettingsDto rowDto,
      BindingResult bindingResult,
      @RequestParam String destination,
      Model model) {

    if (bindingResult.hasErrors()) {

      setAccountList(reportId, model);
      model.addAttribute(ROW, rowDto);

      return EDIT_ROW;
    }

    String result = "redirect:";

    if (DELETE.equals(destination)) {

      rowService.delete(rowId);
      result += ("/view/reports/" + reportId);
    } else {

      if (rowId == 0) {

        rowDto.setId(null);
      }

      Long resultId = rowService.save(rowDto);

      if (STAY.equals(destination)) {

        result += ("/edit/row/" + reportId + "/" + resultId);
      } else {

        result += ("/view/reports/" + reportId);
      }
    }

    return result;
  }
Beispiel #2
0
  @RequestMapping(value = "/edit/row/{reportId}/{rowId}", method = GET)
  public String getRow(@PathVariable Long reportId, @PathVariable Long rowId, Model model) {

    setAccountList(reportId, model);

    RowSettingsDto row = rowService.getRowSettingsDto(reportId, rowId);
    model.addAttribute(ROW, row);

    return EDIT_ROW;
  }