I`m using Play! Framework 2.0 and I’m new in this framework. How can I return just a json representation of my model in white html page?
What I’m doing is
public static void messagesJSON(){
List<Message> messages = Message.all();
renderJSON(messages);
}
But I get Error : Cannot use a method returning Unit as an Handler
The method you are using is from Play 1.x, it is slightly different in Play 2.0. From the documentation, here is an example of how to reply to a
sayHelloJSON requestThe important part of this from what you are asking is the
return ok(result)which returns a JSONObjectNode.