定义切片定义或属性时,是否可以引用另一个定义或属性而不继承?
我有各种各样的JSP片段,CSS和JavaScript,它们被认为是“常见的”。每个页面肯定不需要它们,因此直接继承似乎不会起作用。
示例:
<tiles-definitions>
<definition name="currentBodyDefinition" template="[...specific body template...]" extends="Components">
<!-- if it's not already defined within Components, add it here -->
</definition>
<definition name="page" extends="pageTemplate">
<put-attribute name="body" value="currentBodyDefinition" />
<put-attribute name="scripts" value="[...???...]" /> <!-- can I reference another definition(s) or attribute(s) here??? -->
<put-attribute name="styles" value="[...???...]" /> <!-- can I reference another definition(s) or attribute(s) here??? -->
</definition>
</tiles-definitions>
答案 0 :(得分:0)
我认为你可以这样做:
<definition name="layout" page="/WEB-INF/tiles/layouts/layout.jsp">
<put name="title" type="string" value="${title}"/>
<put name="header" type="definition" value="${header}"/>
<put name="content" type="definition" value="${content}"/>
</definition>
<definition name="headerDef" page="/WEB-INF/tiles/header.jsp">
<put name="headerText" type="string" value="Header String"/>
</definition>
<definition name="contentDef" page="/WEB-INF/tiles/layouts/contentPage.jsp">
<put name="searchPanel" type="definition" value="panelDef"/>
<put name="somePage" type="page" value="/WEB-INF/tiles/somePage.jsp"/>
</definition>
<definition name="page" extends="layout">
<put name="title" value="Some Title String"/>
<put name="header" value="headerDef"/>
<put name="content" value="contentDef"/>
</definition>