2009-05-29 68 views
3

我正在使用Apache Tiles 2.1進行項目。Apache Tiles 2.1 - 如何防止繼承列表屬性重複?

我遇到了一個問題,即使用列表屬性擴展模板正在創建這些列表項的重複項......每個繼承級別都有一組重複項。

作爲一個例子,這裏是基本定義,並在頁面它會產生:

<definition name="base" template="somePage.jsp"> 
    <!-- snip --> 
    <put-list-attribute name="styles"> 
     <add-attribute value="base.css"/> 
    </put-list-attribute> 
</definition> 

這將產生HTML這樣的,符合市場預期:

<html> 
    <head> 
     <!-- snip --> 
     <link rel="stylesheet" type="text/css" href="../css/base.css"/> 
    </head> 
    <body> 
     <!-- snip--> 
    </body> 
</html> 

如果我延長definiton像這樣:

<definition name="firstExtension" extends="base"> 
    <!-- snip --> 
    <put-list-attribute name="styles" inherit="true"> 
     <add-attribute value="someOther.css"/> 
    </put-list-attribute> 
</definition> 

再次,如預期,我得到這個結果:

<html> 
    <head> 
     <!-- snip --> 
     <link rel="stylesheet" type="text/css" href="../css/base.css"/> 
     <link rel="stylesheet" type="text/css" href="../css/someOther.css"/> 
    </head> 
    <body> 
     <!-- snip--> 
    </body> 
</html> 

但是,如果我延長了前一個問題開始:

<definition name="secondExtension" extends="firstExtension"> 
    <!-- snip --> 
    <put-list-attribute name="styles" inherit="true"> 
     <add-attribute value="evenMore.css"/> 
    </put-list-attribute> 
</definition> 

這第二個層次擴展產生這樣的:

<html> 
    <head> 
     <!-- snip --> 
     <link rel="stylesheet" type="text/css" href="../css/base.css"/> 
     <link rel="stylesheet" type="text/css" href="../css/base.css"/> <!-- note: duplicate! --> 
     <link rel="stylesheet" type="text/css" href="../css/someOther.css"/> 
     <link rel="stylesheet" type="text/css" href="../css/evenMore.css"/> 
    </head> 
    <body> 
     <!-- snip--> 
    </body> 
</html> 

「原始」 列出了繼承的屬性爲每個擴展定義重複一次,即使該定義沒有向列表屬性添加任何內容。

我試圖讓我的定義非常幹,所以在某些情況下我有4-5級的繼承。因此,即使只有「最低」定義是唯一一個將另一個css文件添加到列表的情況下,「始終使用」的css文件也會被複製爲4-5倍

這是一個瓷磚的錯誤,或者我只是用一種沒有意圖的方式使用它們?有什麼辦法可以解決這個問題,而不需要簡單地消除inherit="true"?如果可能的話,我想避免在每一個定義上寫出相同的「核心」CSS和JavaScript文件。

回答

2

原來,這確實是Apache tiles 2.1.2中的一個bug,而不是我的配置問題。

已固定,將被包含在2.1.3更新:

tiles JIRA issue了。