コード例 #1
0
  @RequestMapping(value = "/create", method = RequestMethod.GET)
  public String showCreateForm(Model model) {
    TicketsInvoice ticketsInvoice = new TicketsInvoice();
    List<Employee> employees =
        employeeService.findAll(Employee.EmployeePosition.MAIN_CASIER.getId());

    model.addAttribute("ticketsInvoice", ticketsInvoice);
    model.addAttribute("employees", employees);

    return "ticketsInvoice/edit";
  }
コード例 #2
0
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public String findOne(@PathVariable("id") int id, Model model) {
    TicketsInvoice ticketsInvoice = ticketsInvoiceService.find(id);
    if (ticketsInvoice == null) throw new ResourceNotFoundException();

    List<Employee> employees =
        employeeService.findAll(Employee.EmployeePosition.MAIN_CASIER.getId());

    model.addAttribute("employees", employees);
    model.addAttribute("ticketsInvoice", ticketsInvoice);
    return "ticketsInvoice/edit";
  }
コード例 #3
0
  @RequestMapping(value = "/", method = RequestMethod.POST)
  public String createOrUpdate(
      @ModelAttribute("ticketsInvoice") @Validated TicketsInvoice ticketsInvoice,
      BindingResult bindingResult,
      Model model,
      RedirectAttributes redirectAttributes) {
    ticketsInvoiceValidator.validate(ticketsInvoice, bindingResult);
    if (bindingResult.hasErrors()) {
      List<Employee> employees =
          employeeService.findAll(Employee.EmployeePosition.MAIN_CASIER.getId());
      model.addAttribute("employees", employees);

      return "ticketsInvoice/edit";
    }

    return handleSaving(ticketsInvoice, ticketsInvoiceService, redirectAttributes, null);
  }