Apache Tiles 2.1 - How to prevent duplicate attributes of inherited lists?

I am working on a project using Apache Tiles 2.1 .

I have a problem when expanding templates with list attributes creates duplicates of these list items ... one set of duplicates for each level of inheritance.

As an example, here is a basic definition and the page that it will produce:

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

This will create html as expected:

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

If I decipher the definition as follows:

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

Again, as expected, I get this result:

<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>

However, if I continue the previous one, the problems will start:

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

This second level extension gives the following:

<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 4-5 , "" , css.

​​, , ? - , inherit="true"? "" css javascript , .

+3
1

, Apache 2.1.2, .

2.1.3:

. JIRA .

+2

Source: https://habr.com/ru/post/1709357/


All Articles