This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Tiles and variable CSS files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tiles and variable CSS files" Watch "Tiles and variable CSS files" New topic
Author

Tiles and variable CSS files

Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
I'm trying to drop my dependency on tables for layout and move to CSS. I have a struts project using modules and would like to tie a CSS file to each module. So, i have my tiles classicLayout.jsp template and tiles-def.xml definitions and have to use a different classicLayout(1-4) for every module because I can't figure out how to use one layout template and multiple definitions by passing in a CSS file name on an insert. The reason is because the file name has to be rewritten for url encoding:



I want to be able to add to my Layout page something like the following:



and be able to declare the "cssFile" by an insert tag.

Has anyone solved this problem before?


jh
Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
Not <insert>. I meant <put> tag.
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
yes, guess i solved it.. but took me some time... :-)

from tiles.def:


from the jsp:



from the jspf which renders the header:



that should solve your problem,

:-)

jan
[ October 17, 2006: Message edited by: Jan Groth ]
Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
Thanks.

I'm not familiar with the @import label. I'm assuming j2se5, right? I'm not able to find documentation on it, mostly because google doesn't include the '@' in the search. How does the url rewrite occur? You are using a simple html <style> tag and there is no implicit struts based url rewriting going on.
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
wrong. no java 5, simple css import command for styles.

check here, or google on how to import external style files
http://www.topxml.com/css/css_rule_import.asp

i dont understand your concern about url-rewriting. we are just referencing a style file, and are using tiles to switch declarativly between differnt files. no need to worry about the session.

please feel free to post further questions,
jan
[ October 18, 2006: Message edited by: Jan Groth ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Tiles and variable CSS files
 
Similar Threads
why stylesheet not detected in tiles ?
more than one "html:rewrite forward="style"/" possible???
Tiles and struts 1 , not redirecting to tileĊ› definition path
Mr. Ford, Please Help With My Tile Problem
Access resources from jsp without using "bean:message" tag