tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <antonio.petre...@gmail.com>
Subject Re: how to add the js refer in the page which extends the template
Date Tue, 15 Feb 2011 14:14:44 GMT
2011/2/15 maven apache <apachemaven0@gmail.com>:
> And now I need some javascripts in the home.jsp,however I do not know where
> to add it.
> I can add it in the home_body.jsp,but I prefer to add it in a external
> file,so where to define it?
> I mean where to write this  <script ... src=xx.js /> ?

This is the way I prefer, however I think there is plenty of similar,
or better, solutions.
First of all, identify the outer template, the one containing the
<HEAD> elements.
In this template, import a list attribute and iterate over it to
create all script elements:

<tiles:importAttribute name="scriptList" />
<c:forEach values="${scriptList}" var="script">
<script src="${script}" ...></script>

In all your definitions (or on all base definitions you have) put
these attributes:

<definition name="...." template="_thetemplateabove_">
<put-list-attribute name="scriptList">
<add-attribute value="/scripts/xx.js">

Do you like it?


View raw message