问题
I want to have some nested templates with tiles, but without any luck for the moment.
My main template :
[...]
<div id=body><tiles:insertAttribute name="body"/></div>
[...]
My nested template:
[...]
<div id=sub><tiles:insertAttribute name="sub"/></div>
[...]
My view definition:
<tiles-definitions>
<definition name="mainTemplate" template="/mainTemplate.jspx">
</definition>
<definition extends="mainTemplate" name="subTemplate">
<put-attribute name="body" value="/subTemplate.jspx"/>
</definition>
<definition extends="mainTemplate" name="myView">
<put-attribute name="sub" value="blablabla"/>
</definition>
</tiles-definitions>
What I expected :
<div id=body><div id=sub>blablabla</div></div>
What I got :
<div id=body><div id=sub></div></div>
I have seen the documentation on the tiles website about this subject but I can't make it work :(
回答1:
Actually, "subTemplate" and "myView" are two different definitions extending "mainTemplate" both. From what I understand you want the"myView" tile to be nested inside the "subTemplate" tile.
You could try something like this :
<tiles-definitions>
<definition name="mainTemplate" template="/mainTemplate.jspx">
<definition name="subTemplate" extends="mainTemplate">
<put-attribute name="body">
<definition template="/subTemplate.jspx">
<put-attribute name="myView" value="blablabla" />
</definition>
</put-attribute>
</definition>
</tiles-definition>
来源:https://stackoverflow.com/questions/10827403/nested-templates-with-tiles