@RequestMapping(value = "/admin/editnote/{id}", method = RequestMethod.GET)
public String editNoteGet(@PathVariable("id") Long id, Model model){
model.addAttribute("note", noteService.getById(id));
model.addAttribute("version", noteService.getById(id).getVersion().toString());
return "admin/editnote";
}
@RequestMapping(value = "admin/editnote/{id}", method = RequestMethod.POST)
public String editNotePost(@PathVariable("id")Long id,
@ModelAttribute("text")String text,
@ModelAttribute("version")String version,
@ModelAttribute("note")Note note){
note.setCreationDate(noteService.getById(id).getCreationDate());
note.setUsers(noteService.getById(id).getUsers());
noteService.saveNote(note);
return "redirect:/admin/notelist";
}
@RequestMapping(value = "/admin/editnote/{id}", method = RequestMethod.GET)
public String editNoteGet(@PathVariable("id") Long id, Model model){
model.addAttribute("note", noteService.getById(id));
model.addAttribute("version", noteService.getById(id).getVersion());
return "admin/editnote";
}
@RequestMapping(value = "admin/editnote/{id}", method = RequestMethod.POST)
public String editNotePost(@PathVariable("id")Long id,
@ModelAttribute("note")String text){
Note note = noteService.getById(id);
note.setText(text);
noteService.saveNote(note);
noteFileWriter.writeNoteToFileWithFOS(note.getId().toString(), text);
return "redirect:/admin/notelist";
}
@Version
private Long version;
@Lock(LockModeType.OPTIMISTIC)
?
Стоят обе версии на компьютере.