How do I (or should I?) access the service layer from a SiteMesh template (views/layouts/main.gsp) in Grails?
- by knorv
I need to create a toplist in the page footer on a site that I'm building. The footer is created in the default SiteMesh layout template (views/layouts/main.gsp).
In order to create the toplist access to the database is needed, so I've encapsulated all logic needed for the toplist creation in a service class (services/FooService).
Please note that while services are usually accessed from the controller layer, in this case the default layout template (views/layouts/main.gsp) is not generated from a controller.
Can the layout view (views/layouts/main.gsp) access a service class? How?
Is this the correct design decision? If not, what is a better encapsulation and how do I interact with said encapsulation from the layout view (views/layouts/main.gsp)?