methode handler for a layout

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

methode handler for a layout

Mohaed.Amine
Hi,

I have a very simple question about Thymeleaf view engine.
Is it possible to execute a java method that add same context variable to a layout before it is loaded.

Explication:
suppose that we want to load data from the database in our layout (exemple :notifications). I want to execute a code before loading a Thymeleaf layout page that will declare and add a context variable to the layout.

I know that I can load the variable from my controller but this is not a good solution giving that i have to load it in every page that need the layout.
Thank you.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: methode handler for a layout

Metroids
Use a filter to add it to your context.

or

Instead of putting it on your context, put it in a separate controller altogether and call it using ajax.
Loading...