Reputation: 11
I have a gsp and I would like to to render a new gsp from the existing gsp.
I used:
g:render template="testTemplate" instance="${testInstance}"/
But I am not getting the values from the instance in the new gsp.
Would appreciate any help.
Upvotes: 1
Views: 135
Reputation: 7505
Here, I would like to explain render other way around.
Basically render could be used to parse text, gsp or jsp pages.
It is used on Controller,gsp pages to render some text. So,if you know how to pass a bean or model from controller you should be doing same on gsp page.For example, on controller you do something like below:
class TestController{
def show(){
Object object = Object.get(params?.id)
render template:'show',model:[instance:object]
}
}
Hence, on gsp you could use similar in tag too.
<g:render template="show" model="['instance':testInstance]"/>
or
<g:render template="show" bean="${testInstance}"/>
or a collection
<g:render template="show" collection="${testInstances}" var="instances"/>
Here, the collection would be accessible using variable instances
.
For me, the most important thing to understand is render works same way for gsp as it works for controllers except the <
and >
for supporting html.
Upvotes: 1
Reputation: 4373
You can do like:
g:render template="testTemplate" bean="${testInstance}"/
See http://docs.grails.org/latest/ref/Tags/render.html
Upvotes: 0