A picture says more than a thousand words, right? That’s why a web site needs images. In the old days before DD4T, the approach was very simple: out of the box, Tridion would publish your images to the file system, where the web server could pick them up and serve them out to the world.
But in the era of dynamic publishing, who wants to deploy to a file system anymore? One of the advantages of DD4T (or DXA, or any other dynamic framework) is that you publish everything to one central delivery store: the broker database. It makes sense to use this approach for images (and other binary file types) as well. But how?
SDL Web 8.5 (formerly known as SDL Tridion) is just around the corner. This release introduces a number of new features in Content Manager and functional changes in Content Manager Explorer, Content Delivery, Audience Manager and Translation Manager. Experience Optimization, formerly called SmartTarget, is part of SDL Web as of this release.
On a recent project of ours (Java/SDL Web 8/DD4T 2), the customer’s architect suggested to use a view language that I had – quite frankly – never heard of: Thymeleaf. I had always wondered why the Java world had never settled on a view technology to replace JSP. The way I see it, JSP has had a great run (it’s been around since 1999) but it belongs in the same category as ASP – a moloch from times of old. Although you can use JSP as the ‘V’ in ‘MVC’, it has never been a true view language. The support of inline java code means that developers can easily run amok, which can lead to messy and hard to maintain code bases. Also, JSP writes it output directly to the response, making it less flexible than more modern view technologies.
I have been waiting for a Java equivalent to .NET’s Razor: neat, clean syntax, intuitive switching between code and markup, and very well integrated into the framework. So when Thymeleaf was suggested, I thought – perhaps – this could be it!
In one of our current projects, we are using two-tiered web delivery approach:
- Static files (images, js, css, etc) are served by Apache Httpd, a simple web server
- Pages and dynamic component presentations are served by Tomcat
Our technology stack includes Web 8, DD4T 2, Spring MVC and Java 8.
One of the unwritten rules in MVC is that ViewModel classes should be kept very simple. They should basically represent data to be displayed in your views. Then, depending on the concrete implementation and the requirements, the whole mapping and connecting it all together part does not always stay simple.
The usage of ViewModels in DD4T 2.0 can actually be very simple, as the example code will try to show. Anything with a simple basis should be also extendable in an easy way and that is the main goal of the framework.