1

I am developing a jsp web application, no framework (sadly...), that will be used for differents customers. Each customer have their own set of colors and company logos.

The css layout will not change, only some divs colors, font colors, button colors, so and so.

I trying solve this problem implementing a filter that receive a general request and then redirect the request to correct folder depending on the customer.

By example, the index.jsp request css/index.css, then filter verify the customer and then change the request to 'customer1_css/index.css'. This works fine, by now...

But, when I need to add or modify some css element, I have to do it in each css file of each customer.

I want to simplify this process for us and the web designer. So, I though in using FreeMarker, parametrizing all dynamics elements, and make a db table where I put each parameter value. But is very cumbersome.

I know that I am not the first developer with this problem.

Please, give me some ideas for solve this.

Thanks in advance!!!

nashuald
  • 805
  • 3
  • 14
  • 31
  • Isn't your concrete problem more that you've violated the DRY principle and copypasted the shared code over all loose CSS files instead of having only one shared CSS file along with customer-specific CSS files? In other words, every customer should end up retrieving two CSS files: a shared one and a customer-specific one. – BalusC Aug 07 '12 at 17:57
  • Yes. You got the reason. But, I even so, imagine that you have 15 customers. This mean 15x(no shared css files) modifications. – nashuald Aug 07 '12 at 18:20

1 Answers1

0

I would stay away from generating the CSS dynamically. If you change the layout of the page so that it requires a change to the CSS, there's nothing you can do but make all the changes in the CSS files. How would you stay away from that by generating the CSS dynamically? You'd still be restricted to only changing the properties (class names, ids) you've decided upfront.

A better solution involves writing semantic HTML, that is, improve your HTML so changing its layout doesn't require as many changes to the CSS See How to avoid locking my HTML structure when using jQuery to create rich client experiences?

Community
  • 1
  • 1
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217