This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Question

 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using Tiles in out application. We have a defintion of headerBodyFooter and then extensions of that defintion for particular body JSPs.

I need to include a reference to Java Script file or maintain JavaScript in the "body" jsp. The body JSP does not include the <head></head> tag as that is located in the layout. Including the script rerefence in the body without it being in <head> does not conform to HTML standards I beleive.

Any recommendations of how you have acheived this?

Thanks in advance.
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can achieve this by configuring the path of javascript file in the tiles definition and expose that
name in the master layout. The child definitions can override the javscript file value
and thus can render different javascript files within the <head> element itself.
Please take a look at the following code snippets:
tiles-defs.xml


masterlayout.jsp:



Hope this helps.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks much for the tip. This would work great except we have a case where we include multiple JS files. Any ideas on the same?
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that is the case, you can still have them using tiles. Move the script elements generation into a separate tile with a JSP. You can configure multiple JS files in tiles-defs.xml. The following code snippets would help you:
tiles-defs.xml:



jslayout.jsp:



Hope this resolves your requirement.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does.Thanks much :-)
 
Vidhir Kaup
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was stuck with the same problem. Your response helped me solve it. Thanks a lot.

Originally posted by Kalichar Rangantittu:
Thanks much for the tip. This would work great except we have a case where we include multiple JS files. Any ideas on the same?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great solution, Durgaprasad!

I've included it in the Struts FAQ. I hope you don't mind. If you do, just let me know, and I'll take it out.

Cheers,

Merrill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic