Nested templates with tiles

佐手、 提交于 2019-12-24 14:09:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!