I have a very long templates for report. It contains more than 50 Grails domain at once. But when I tried to load up to 25 domain, it said "Invalid method Code length". I did search on google and it recommend me to split / chuck the templates.
So I made the following changes:
before it was one template _template.gsp
but now : _template.gsp and _template2.gsp
but inside _template.gsp I put code such as
Now the problem It won't allow to load model/objects that loaded in controller into template2 ....
in my controller:
Class Ab开发者_如何学运维cController{
def index = {
def myParrent = MyParrent.get(1);
def mode = [:];
model.obj1 = Obj.findAllByParrent(myParrent);
model.obj2 = Obj2.findAllByParent(myParrent);
...
model.obj50 = Obj50.findAllByParrent(myParrent);
model.obj51 = Obj51.findAllByParent(myParrent);
def str = render(template:"template", model:model);
render(str);
}
}
any idea why model loaded in _template.gsp but not recognized in _template2.gsp
edit:
_template.gsp would like this one (not as simple as this one, because for each domain object I have to display one by one its fields)
<html><body>
<div>${obj1}</div>
<div>${obj2}</div>
<div>${obj3}</div>
....
<div>${obj24}</div>
<div>${obj25}</div>
......
<g:render template="template2"/>
.....
</body></html>
_template2.gsp:
<div>${obj26}</div>
<div>${obj27}</div>
<div>${obj28}</div>
........
<div>${obj50}</div>
So in a page I would like to display about 50 domain at once (the purpose is for filling the form, so don't blame me if I have to display all the data at once ... )
Thanks
You need to pass the model(s) into the other template:
<g:render template="template2" model="[key:value]" />
精彩评论