• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Same backend, quite similar HTML but CSS different.

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

We are using Java Spring and Thymeleaf and I have received a task to change an existing application. The change is to create a new set of webpages but with the menu removed while maintaining the existing functionality. The existing webpage should be left untouched.

The new webpages will be called from another application using its absolute URL.

In addition, the new webpages will have a new set of colours for the buttons and backgrounds, etc. ie: a new CSS.

The previous developer has copied the html webpages and made changes to the CSS. To maintain the functionality, the developer has copied the controller to a new controller for the webpages.
This created a lot of code duplication in the controllers.

I would like to ask what is the best approach to this situation without code duplication.

Feel free to ask any points that I may not be clear. Thank you.
 
Author
Posts: 12
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder if the changes that you need to do can be done in CSS only. If that is the case, you could conditionally load different CSS files depending on a model attribute you set in the controller. That way, you can have 1 controller with just 2 methods that delegate to a single private method with the actual controller logic without duplication.

Something like this:



In your Thymeleaf template, use the `cssLink` variable to point to the CSS file.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic