-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Play Framework essentials
By :
The two routes of our application using the GET verb (Items.list and Items.details) now return an HTML page. However, the remaining routes are not currently reachable by our web users. Web browsers can perform POST requests only when an HTML form is submitted or if some client-side code sends an XmlHTTPRequest.
Let's add an HTML page that contains a form to create new items, which will look like the following:

First, we need to define an HTTP endpoint for the page containing the form and then write the according route:
GET /items/add controllers.Items.createForm
Note that as routes are tried in their definition order, this route must be defined before the Items.details one, as their URL pattern overlap.
Then, we define the corresponding action in the Items controller:
val createForm = Action {
Ok(views.html.createForm())
}The Java equivalent code is as follows:
public static Result createForm() {
return ok(views.html.createForm.render());
}This action just...
Change the font size
Change margin width
Change background colour