Hi I’m learning Play Framework 2 with Java and have a problem. I use MongoDB, and have a simple class User with ObjectId as unique id.
public class User {
@JsonProperty
public ObjectId id;
..
in my view I want to add a button to delete current user, something like this :
@form(routes.Application.deleteUser(user.id)) {
<input type="submit" value="Delete">
}
and in my routes file :
POST /users/:id/delete controllers.Application.deleteUser(id: org.bson.types.ObjectId)
But now I got an error :
“No URL path binder found for type org.bson.types.ObjectId. Try to implement an implicit PathBindable for this type”
I tried a lot of things, for example I tried to pass only the ObjectId value as a String, but nothing worked for me. Can anyone please help me with this ?
You could use play-salat which have neccessary binders, just add it as a dependency to your
project/Build.scalaand import it to your routes and templates:Also take a look to this example application.