Customer Use case
Our customer had a requirement to send some HTTP headers with the last publication date of the page in it, in order to optimize browser caching. For this reason we needed to include the last published date from Tridion in our DD4T PageModel.
The DD4T ViewModel functionality lacks the option to include the last publish date. Fortunately, you can create your own attributes.
In this blog I will show you how easy it is to create a custom attribute to include the last publish date of a page in your models. Continue reading
Plato (~423 BC – ~347 BC) was a pretty smart guy. Among his many ideas and thoughts, his Theory of Forms had an immense influence on how we perceive and solve the philosophical Problem of universals. It basically comes down to the idea that every physical object has one or more essences (or Forms) and that if that object would not have that Form, it would not be that object: a dog is Mammal, but a giraffe is also a Mammal. What makes both animals Mammals? It’s, simply put, the Idea of the Mammal.
In part II of these series on ViewModel functionality in dd4t–2-java, it was explained how to create ViewModel classes and how to implement basic field types for the mapping between Tridion fields and DD4T ViewModel properties.
This post handles the more complex field types. The reason we make a distinction between ‘simple’ and ‘complex’ is mainly because the complex field types have more options to be deserialized into and need quite some help from DD4T to know what they will become.
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.
In the previous article in this series, we had an in-depth look into how the ViewModels mechanism works in DD4T 2 for Java. This part covers the practical aspects and the basics on how to create your own ViewModels as well as having a look at how Tridion field types map to Java Object types.