Nested templates with tiles

2019-08-05 17:49发布

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条回答
成全新的幸福
2楼-- · 2019-08-05 18:46

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>
查看更多
登录 后发表回答