1

some background info:

I am using simple Spring Theming right now. The spring controller code pulls the appropriate view, ex: WEB-INF/view/appropriateView.jsp. The views all have the same basic html with classes that a design .css file can theme. The view sets the design file via spring:theme code like so: <link rel="stylesheet" type="text/css" href="<spring:theme code="css.layout_style_sheet"/>" />. The WEB-INF/classes/theme-theTheme.properties file will define what css file to use via: css.layout_style_sheet=theme960/960.css.

Thats all fine and dandy for themes that are based on the same css framework (like using 960.css, 1024.css, 800.css, etc for the 960 framework) and the html will looks exactly the same minus 1 different css file. But now we want to use Twitter Bootstrap or Zurb Foundation or 960, etc. On appropriateView.jsp, TwitterBoostrap will want to use different js files to include to use its framework vs Foundations. Also the html content will be different since they use different html data-attribute tags to let its framework know how to present things visually plus the markup may be totally different as well: <div class="navbar"><div class="navbar-inner">... vs <nav class="tab-bar"> <section class="left-small">...

My best idea was to have different files for each main css framework like appropriateView-twitter.jsp, and appropriateView-foundation.jsp and in the spring controller code pull the appropriate one. and inside that file then there may be different 'includes' for each framework (guess can just pass a variable to get it like datepicker-${cssfrawework}.jsp). like datepicker-twitter.jsp, datepicker-foundation.jsp and radiobuttongroup-twitter.jsp, radiobuttongroup-foundation.jsp. maybe the design wants to add a different number of css/js-plugin files in addition to those included by the base cssframework template.

My question is now, is there a better way to do theming like this via more advanced java theming/template engines like Velocity, SiteMesh, Mustache, ThymeLeaf,etc Vs my idea above? and if so, any examples on the web to show an advanced theming system like this in action? It would be great if designers could work on these files via in their Designer IDE of choice (guess this is what ThymeLeaf calls 'Natural Templating').

armyofda12mnkeys
  • 3,214
  • 2
  • 32
  • 39
  • consider doing the templating on the frontend on not on the server, using a framework like angular.js or handlebars.js http://handlebarsjs.com/ . With this design there is no longer html and css generation on the server, the spring services are just REST (stateless) services serving data in usually JSON, that can be easilly integrated with any other application, desktop/mobile etc. only data is served by the services, not Html/CSS. The templates are in plain html and CSS, solving the problem of making the templating more natural for designers – Angular University Feb 17 '14 at 21:02
  • possible duplicate of [Is it possible to decorate more than once in Sitemesh?](http://stackoverflow.com/questions/5329693/is-it-possible-to-decorate-more-than-once-in-sitemesh) – Paul Sweatte Jun 12 '14 at 22:46

1 Answers1

1

If you want to support different CSS-Framework I think you must write for every framework your own html. If you use Spring MVC a Custom-ViewResolver can find the right template. For the themes I would use strong naming convention like main-boostrap2-ibm.css. So you know the theme boostrap2-ibm uses bootstrap and can reference in thymeleaf main-${themename}.css.

niels
  • 7,321
  • 2
  • 38
  • 58