Question

With Grails, is it possible to get the name of the view that is being rendered while in the layout GSP file? I'd like to change one minor thing in the layout file depending on which view is going to be rendered.

Was it helpful?

Solution

If found this to be rather difficult to determine. It's easy if you use conventions, but you can always explicitly render any view you want. See the code in How to detect which view file has been rendered in grails for how to determine this in a filter.

OTHER TIPS

The name of the view is normally the same as the action that has just been executed (e.g. show action normally renders the show.gsp view) - if this is the case in your view, then you can get it in your layout gsp using ${actionName}.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top