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: Resource import on individual pages
Date Sat, 12 Dec 2009 11:49:34 GMT
2009/12/11 anyz <anyz111@gmail.com>:
> I have a base tile definition and various tiles extend it. The static
> resource like css, js are imported throuhg <link> and <Script> tags in base
> tile. Similalry various java files are imported though import directive in
> base tile jsp page. However each child type has its own js, css and java
> import file. How can i import resources for individual pages instead of
> putting everything in base tile. Also html <body> and <head> tags are
> present only in base tile so is it good practice to import resource in child
> tiles even then.

As Brian anticipated, I have another suggestion :-D
You can make use of list attributes. I suppose that you have *several*
js and css files to point to, so in your template page you can do this

<tiles:importAttribute name="javascripts" />
<c:forEach var="jsfile" items="${javascripts}">
<script type="text/javascript" src="<tiles:getAsString
value='${jsfile}' />"></script>
<!-- The same for css -->

Your definition becomes:

<definition name="my.definitio" template="/my/template.jsp">
  <put-list-attribute name="javascripts">
    <add-attribute value="/js/script1.js" type="string" />
    <add-attribute value="/js/script2.js" type="string" />


View raw message