I am quite new to grails. I just noticed that variables in the controller are not visible in the view. I only can get the variable values when I assign it to a scope. Is this the standard Grails way or am I doing this wrong. Also, is the params scope the correct one to use or should I use sessions, servletContext?
In the Controller
String uploadLocation = grailsApplication.config.uploads.location.toString()
params.put "upLoc", uploadLocation
In the View
<td> <input type="text" value="${params.get('uploc')}/${fileResourceInstance.decodeURL()}"></input></td>
I’m very familiar with Ruby on Rails and this is handled very differently in RoR. Thanks.
You can do it like Maricel say, but there’s another way (I think it’s a default way to do): return the values you want to pass to the view in action function. For example
Then in view you can access ${testInView}, ${numInView}
Another slightly different way: you can neglect the “return” keyword, it’s “groovy way” to return the last value of the function.