Play! framework calling the render () action from the controller

I set up the template generated by the CRUD module, and now you need to override the save method to save user data from the template. I can save all the data, but when I call the render action:

render("Users/show.html", user); 

I get a nullPointerException object for templates:

enter image description here

I definitely pass the correct user object because when I run this:

 System.out.println(user.toString()); //render("Users/show.html", user); 

It writes my user to the console.

Any help would be greatly appreciated.

Controller Preview

Play! 1.2.3

+4
source share
1 answer

Your controller is rendering

 render("Users/show.html", user); 

but the element name in your template is an object. He must be a user.

UPDATE IN COMMENT

CRUd source templates use an “object” as an abstraction for an object under CRUD. If you check the source code of the controller, it says:

 //ignoring case when template is not found, alternative also uses object render(type, object); 

This means that there are two options:

  • You have modified a template that violates this compatibility. This is not like your scenario, although we cannot see the full code (so this may be an option)
  • You have changed the controller by changing the objects that you submit to the template. This seems to be your scenario. Therefore, either you will correct the template to use the user, or rename the user to an object.
+6
source

All Articles