There are two ways to incorporate common view code into a playback platform.
You can use the tag #{include} or the tag #{extends} .
The extends tag, as the name suggests, extends from the parent view. The extends tag is used by default in the skeleton code set by Play when creating a new application. It extends main.html. You add your code here.
Includes a tag, allows you to embed the general part of the view code in your templates at the specified point. This works almost the same as php include / require, or jsp includes work.
The problem will come when your code template also requires data or logic from the model (via the controller). If so, then you will need to use the @Before or @With notation in your controller to ensure that the common piece of controller code is executed every time. You can add any data to the renderArgs list so that it is available for use in the view.
A simple example of using renderArgs would be.
@Before private static void commonData() {
the values you enter in renderArgs (the menus and selected in the example) will be available exactly as if you passed them to the rendering method.
Codemwnci
source share