358 CHAPTER 8: Play with Java and Scala
Note A controller is a type that extends the controller provided in the play.api.mvc package.
Model
The model is the domain-specific representation of the information on which the application operates.
The most commonly used object for this representation is the JavaBean. However, JavaBeans lead
to plenty of boilerplate code. Play 2, like Grails, reduces this boilerplate code by generating the
getters and setters for you by means of byte-code enhancement. The model objects may contain
persistence artifacts such as JPA annotations, for instance, if they need to be saved into
persistent storage.
Note Even if Play 2 uses Ebean for ORM, you can continue to use JPA annotations on your entities.
View
In a Java EE–based web application, the view is usually developed using JSP. That is, the view in
a Java EE–based web application consists of JSP elements and template text. As Play is not Java
EE–centric, the view in Play comprises the template that contains a mix of HTML and Scala code.
In Play 1, the templates were based on Groovy, but starting with Play 2, the templates are based
on Scala. Using Play 2 you can develop both Java- and Scala-based web applications, and the
templates are the same in both of them.
Note In Play 1 the templates were based on Groovy, but starting with Play 2, the templates are based on Scala.
Getting Started with Play
To run the Play framework, you need JDK 6 or newer. You can download Play 2 from here: http://www.
playframework.com/download. Play 2 is available in two distributions: standard and Typesafe
Activator.
Download the latest stand-alone Play distribution, extract the archive to a location of your choice,
and update the Path environment variable by adding/editing the Path variable in the Environment
Variables dialog with the path to the Play installation, as illustrated in Figure 8-2.