In this section, we'll cover the basis of dealing with data, both on the client side within HTML views and the server side by manipulating a domain model.
Actually, Play! 2 provides helpers and commodities for these two sides and eases their integration, even if a wire transfer occurs in between them.
We'll start by allowing the user of our application to provide some data, and the most common way to do that is by using HTML forms. Hence Play! 2 brings a shared concept for forms on the client and server sides.
The Play! 2 data API is based on the notion of a form to declare a structure. For that, the framework contains a fully-fledged API that resides under the package play.api.libs.data
, wherein we'll find the Form
class. In order to learn how to use it, we'll see how to create a user of our application.
We'll start with the simplest User
structure ever:
Ok, for now our User
class is just a wrapper around a name; of course, it will be enhanced further...