Reputation: 661
In Play!, I want to log something after I executed a controller action, using the @Finally annotation. However, I need some data from the database I sent to my view. Is it possible to access this data in the @Finally annotated method?
This is the method in particular:
@Finally
private static void logSomething() {
//System.out.println("User: " + u.first_name);
System.out.println(response);
for (String key : response.headers.keySet()) {
System.out.println(key);
}
}
How can I pass parameters to this? If I put a parameter in the definition, it's always null (cause how should this method even know what data to pass?).. so is it possible?
Upvotes: 1
Views: 269
Reputation: 54924
If you sent it to your view, then it will be available from the renederArgs
map.
So, assuming you called your render method in some way like this...
User user = User.findById(someId);
render(user);
Then you should be able to access it in renderArgs as follows
User user = (User)renderArgs.get("user");
Upvotes: 3