Thank you Antonio. This is great stuff. I do have one follow up question to this however.
This solution requires me to place additional definitions in the xml file for every page I have, since they all would have some kind of unique JavaScript. I would then use the extended definition in my custom page. Is there any way to not define the new JavaScript in the xml config file and to include it in the custom jsp that uses the master layout either by including a custom JavaScript file or have custom JavaScript inline in the custom jsp? I would prefer to not have a lot of xml in the tiles xml file. I am only trying to use the reuse the definitions for header menu footer in the custom jsps I create. I would like to override the JavaScript and content in the custom jsp files I create. For instance, in all of the examples I see the body tag is in the master_layout.jsp. I want to define the body tag in my custom.jsp that uses the master layout because I might want to call some custom JavaScript at body onLoad. I hope this makes sense? Thanks again for any help. I am just trying to put the pieces together in my head. I am creating a new app. Jeff -----Original Message----- From: Antonio Petrelli [mailto:[email protected]] Sent: Wednesday, July 28, 2010 2:37 AM To: [email protected] Subject: Re: Apache Tiles 2 and javascript and css 2010/7/27 Motley, Jeffery <[email protected]>: > What is the appropriate place/way to define javascipt/css for a jsp that > is using a Tiles definition.? I would like each custom page to use the > master layout but override the body/content section. However I need > custome javascript/css for each page. Use string attributes. For example: <definition name="master" template="/jsp/master_layout.jsp"> <put-attribute name="css" value="/css/default.css" type="string" /> <put-attribute name="script" value="/js/default.js" type="string" /> </definition> <definition name="extended" extends="master"> <put-attribute name="css" value="/css/overridden.css" type="string" /> <put-attribute name="script" value="/js/overridden.js" type="string" /> </definition> And, in master_layout.jsp: ... <head> <tiles:importAttribute name="css" /> <link href="${css}" rel="stylesheet" type="text/css" /> <tiles:importAttribute name="script" /> <script type="text/javascript" src="${script}"></script> </head> HTH Antonio
