Add update/delete to the web-ui sample

Closes gh-4735
See gh-4733
This commit is contained in:
kozazz
2015-12-08 13:07:55 +09:00
committed by Phillip Webb
parent ffbdfc586b
commit 0de4b6ce63
5 changed files with 36 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/**
* @author Rob Winch
* @author Doo-Hwan Kwak
*/
@Controller
@RequestMapping("/")
@@ -73,4 +74,16 @@ public class MessageController {
throw new RuntimeException("Expected exception in controller");
}
@RequestMapping(value = "delete/{id}")
public ModelAndView delete(@PathVariable("id") Long id) {
this.messageRepository.deleteMessage(id);
Iterable<Message> messages = this.messageRepository.findAll();
return new ModelAndView("messages/list", "messages", messages);
}
@RequestMapping(value = "modify/{id}", method = RequestMethod.GET)
public ModelAndView modifyForm(@PathVariable("id") Message message) {
return new ModelAndView("messages/form", "message", message);
}
}