Java Reference
In-Depth Information
11. public static Result newBook() {
12. return TODO;
13. }
14.
15. public static Result deleteBook(Long id) {
16. return TODO;
17. }
18.
19. }
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
1. package models;
2. import java.util.*;
3. public class Book {
4. public Long id;
5. public String label;
6. public static List<Book> all() {
7. return new ArrayList<Book>();
 
Search WWH ::




Custom Search