Labs
You are going to be writing a number of request handlers in the FilmController, as well as adding some supporting methods in the FilmDAO. The goal is to have functional read operations for the Film entity so that a user can view a list of films (a master list) and, after selecting a film, see a detailed view of that film.
-
Add a
List<Film> findAll()method to your FilmDAO. Implement the method in your FilmDAOJpaImpl class using a JPQL query. This method should find all the films in the database and return them as a List . -
In your
/route's method, inject theModelby adding it as a parameter; retrieve the film list from the DAO and add it to the model.
@RequestMapping(path = "/", method = RequestMethod.GET)
public String index(Model model) {
// TODO : Retrieve film list, add it to the model.
return "/WEB-INF/index.jsp";
}
- In your
index.jsp, hyperlink each title such that clicking on a film's title will direct through theshowroute and display that film's detail page. - Use the
getFilm.doroute we set up in an earlier Skill Drill. - You will need to add the
coretag library.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> - NOTE: An example of a hyperlink to the first film might be:
<a href="getFilm.do?fid=1">ACADEMY DINOSAUR</a>
- You will need to dynamically add the film's
idto the query parameter with expression language with the parameter namefid. (They are hardcoded above.) -
You may want to set the database logging level to
WARNinapplication.properties. -
When a film's title is clicked on, the user should be sent to the detail view (
show.jsp) which displays the: -
title
- release year
- description
- length