Alternative alternative

I have a question about the renderArgs variable and where it is in the 2.0 playback platform for Java and scala. As I understand it, templates are now called explicit arguments. You explicitly add beans to your view, for example:

 views.html.Application.index.render(customer, orders); 

I am asking about this for the specific case of the user that I am using in the current Framework application. All controllers are annotated using @With , which implements a simple search if the username is in a session that loads the user account from db and puts it in a renderArgs object.

Then the controller or view can access this bean, if necessary. Very dry. It seems that the play framework 2.0 is seriously undermining this, forcing to explicitly add a bean account for every call of the form, for example:

 views.html.Application.index.render(account, customer, orders); 

Can I advise? Any functionality for this is available but not yet listed in the documentation?

+4
source share
1 answer

You can use implicit variables.

This answer solves the tangential problem, but the idea is to declare an implicit variable and make it available over the scope, so you don't need to pass it.

+2
source

Source: https://habr.com/ru/post/1383891/


All Articles