• Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic handling of stylesheets  RSS feed

 
shruti jain
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to implement a feature which would enable the end user to choose a different skin for a particular page. How should i do this?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd go with a dropdown box.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll guess this is a JSP question, based on his past posting history. Off we go to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of JSP are you using? Or are you using JSP at all?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A simple JSP 2.0 implementation:

Set up your web app such that you have a folder structure (relative to the context root) like so:



where skin-name is the name of each of your "skins" (or "themes" as I usually call them). The stylesheets and images for each separate theme would go in their respective folders.

Call one "default" which is used when no specific skin is specified.

Now, since the current "skin" is specific to a user, store the skin name in the session as a scoped variable named 'skinName'.

On page, do something like:



Of course you would have to do the same for each stylesheet. And you'd need to adjust the URL of any images likewsie.

The approach I've actually used is along the lines of the above, but keeps the goo off the pages by setting up a small custom tag library which includes replacement tags for images and stylesheets (as well as for Javascript files in case they change theme to theme) that adjusts the URLs to the resources as approriate to the value of the current skin for the user. (The tags are also smart enough to pick up any missing resources from the 'default' theme so that resources that don't change across themes don't need to be copied -- but that's frosting).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!