Search code examples
grailsgsp

How to find where is an object declare in GSP


In a gsp file there is line like below

<g:each in="${tools}" var="tool" status="counter">

and when i debug it shows value like below

enter image description here

It's using Grails framework. May I know how can I find where is this ${tools} declared and being called from to this GSP?


Solution

  • Grails uses convention over configuration. So in order to trace back where tool is being set, you have to note the name of the gsp file and the directory in which it is placed.

    Ideally if the gsp name is bar.gsp and is placed under foo directory under grails-app/views then the convention is that there could be a FooController.groovy under grails-app/controllers which would have an action called bar(). Most likely the model is set with the variable tools inside the baraction.

    This exercise would be a good starting point.