I'm trying to bind a form to a request but it fails with the following error:
Execution exception
[RuntimeException: Cannot instantiate class controllers.Application$RequestData. It must have a default constructor]
The error description seems straight forward and simple, but looking at the code:
public class RequestData {
@Required
public String id;
public RequestData() { }
public RequestData(String id) {
this.id = id;
}
}
public static Result index() {
...
Form<RequestData> requestDataForm = form(RequestData.class);
RequestData requestData = requestDataForm.bindFromRequest().get();
...
}
You can see that the class indeed has a default constructor and so this error is not clear at all.
Any ideas? Thanks.
Edit
What's amusing is that in the official documentation, the example they use do not have a default constructor.