CHAPTER 8: Play with Java and Scala 375
- public static Result newBook() {
- return TODO;
- }
- public static Result deleteBook(Long id) {
- return TODO;
- }
- }
Lines 7, 11, and 15: These lines show the actions that were specified in the
routes file in Listing 8-7.
Lines 8, 12, and 16: A built-in result TODO is used that returns “Not
implemented” response 503. This result tells Play 2 that the action
implementations will be provided later. When you access the application via
http://localhost:9000/books, you see the result displayed in Figure 8-22.
Figure 8-22. Built-in TODO result in Play 2
Creating the Model
The next step is to define the model Book that can be stored in a relational database. For this, create
a class in the app/models/Book.java file, as illustrated in the Listing 8-9.
Listing 8-9. Book.java
- package models;
- import java.util.*;
- public class Book {
- public Long id;
- public String label;
- public static List
all() { - return new ArrayList
();