Play 2.6 - Doubt about query string using bindFromRequest()

97 views
Skip to first unread message

Lucas Tomasi

unread,
Jun 28, 2017, 1:16:17 PM6/28/17
to Play Framework
Hi there!

Currently, I'm using Play 2.5.4 and I'm studying to upgrade both for the newest version. However, I have a doubt:

We are using Play to provide a REST API that manages some resources. Example: we have 2 resources, Car and Activity, so, there is one GET call per resource to retrieve all elements paged. Each these calls got required attributes like start date, end date, page and per page. Also, each call has specific optional attributes like car model, car color for cars and activity type for activities. Example: (* means required)

GET /cars attributes:
*DateTime startDate
*DateTime endDate
*Integer page
*Interger perPage
String model
String color

GET /activities:
*DateTime startDate
*DateTime endDate
*Integer page
*Interger perPage
AcitivityType(Enum) type

Currently, to validate the required attributes and its type, we are using the bindFromRequest() to bound the query string parameters in a Form class. But, on Play 2.6,  I've read the migration guide and noticed that with Play 2.6, query string parameters will not be bound to a form instance anymore when using bindFromRequest(). https://www.playframework.com/documentation/2.6.x/Migration26#Form-changes

What is the best way to handle query string parameters and validate them?



Matthias Kurz

unread,
Jul 1, 2017, 7:51:45 AM7/1/17
to Play Framework
Your code will still work. For GET requests nothing changes. Your forms will continue to work like in Play 2.5 and will still be validated and filled.

The migration guide just says ".. in combination with POST, PUT or PATCH..." the query parameters won't be considered anymore. For GET request they will still be taken into account.

Reply all
Reply to author
Forward
0 new messages