Java Reference
In-Depth Information
Listing 6-20. BookController.java
1. package com.apress.books.controller;
2.
3. import javax.faces.bean.ManagedBean;
4. import javax.faces.bean.RequestScoped;
5. import com.apress.books.model.Book;
6. import com.apress.books.service.BookService;
7. import java.util.List;
8.
9. @ManagedBean
10. @RequestScoped
11. public class BookController {
12.
13. private BookService bookService ;
14. private List<Book> bookList;
15.
16. public String listAllBooks() {
17. bookList = bookService.getAllBooks();
18. return "bookList.xhtml";
19. }
20.
21. public BookService getBookService() {
22. return bookService;
23. }
24.
25. public void setBookService(BookService bookService) {
26. this.bookService = bookService;
27. }
28.
29. public List<Book> getBookList() {
30. return bookList;
31. }
32. public void setBookList(List<Book> bookList) {
33. this.bookList = bookList;
34. }
35. }
Line 17 : Invokes the getAllBooks() method on bookService
Line 18 : Returns the booklist.xhtml file that is composed with the template and
list.xhtml , which displays the list of books see later in Figure 6-20
Listing 6-21 illustrates the configuration metadata that is provided to the Spring IoC container. This
file is the same as created in Chapter 5 with a slight modification to configure the managed bean
BookController with the BookService .
 
Search WWH ::




Custom Search