来自http://tiles.apache.org/2.0/framework/tutorial/advanced/nesting-extending.html
<definition name="myapp.homepage.body" template="/layouts/three_rows.jsp">
<put-attribute name="one" value="/tiles/headlines.jsp" />
<put-attribute name="two" value="/tiles/topics.jsp" />
<put-attribute name="one" value="/tiles/comments.jsp" />
</definition>
<definition name="myapp.homepage" template="/layouts/classic.jsp">
<put-attribute name="title" value="Tiles tutorial homepage" />
<put-attribute name="header" value="/tiles/banner.jsp" />
<put-attribute name="menu" value="/tiles/common_menu.jsp" />
<put-attribute name="body" value="myapp.homepage.body" />
<put-attribute name="footer" value="/tiles/credits.jsp" />
</definition>
我需要扩展myapp.homepage
并在扩展定义中我需要向myapp.homepage.body
添加另一个属性。希望它有意义。
答案 0 :(得分:1)
我终于能够解决问题了。答案如下:
<definition name="myapp.homepage_extended" extends="myapp.homepage" >
<put-attribute name="new-attr-in-body" value="/tiles/new-attr-in-body.jsp" cascade="true" />
</definition>
诀窍是添加cascade="true"
,以便属性可以级联嵌套定义。
答案 1 :(得分:0)
<definition name="myapp.homepage.extended" extends="myapp.homepage">
<put-attribute name="yournewattribute" value="My New Attribute" />
</definition>
!-- Note: you can also use this pattern to override an attribute. All the other attributes will remain:
<definition name="myapp.homepage.override" extends="myapp.homepage">
<put-attribute name="tiele="My New Title" />
</definition>
!-- Or you can combine overrrides with additional attributes:
<definition name="myapp.homepage.custom" extends="myapp.homepage">
<put-attribute name="tiele="My New Title" />
<put-attribute name="yournewattribute" value="My New Attribute" />
</definition>