Before Liferay 6.2 the only way to customize your plugin functionality required a deployment. If you wanted to change how your portlet can display data, you’d deploy your theme, hook or a portlet. Or a combination of those. Luckily Liferay developers thought this through and decided that it does not need to be this way. And behold! Application Display Templates (ADT) framework was introduced as a part of Liferay 6.2.
What Do Application Display Templates Do?
By using ADT you are able to change the way your portlet displays data on the go. You can select from predefined views created by the plugin developer or even create one of your own. The ADT framework is applied to several Liferay portlets out of the box, Asset Publisher, Media Gallery and Site Map to name a few.
What Does It Actually Mean?
Let’s say, in a time before Liferay 6.2, you wanted to create a custom view for your Asset Publisher listing. The default way would have been to create a hook to add new display style for the portlet and deploy it. Now what you need to do is to add new ADT for Asset Publisher portlet through site configuration. Whether it’s global for all sites to use or site-specific, that’s up to you to decide. You can use either Freemarker or Velocity script to completely redesign the structure and even functionality of your plugin. And by the way, Liferay even offers a pre-configured palette and autocomplete to help you with your customization. And no redeployment necessary!
And the awesomeness doesn’t even stop there. You can use ADT in your own plugins as well. With a few simple steps you are able to fully use the framework to deliver an application which offers the freedom to add and edit views without redeployment.
Sounds Great, But Is This Easy?
In his blog post, Eduardo Garcia introduces a four step program to add Application Display Template support to your portlets.
In short, what you need to do is:
– Create custom PortletDisplayTemplateHandler
– Grant permissions for the portlet to use ADT
– Add display settings configuration by using Liferay’s ddm-template-selector taglib
– Extend your view code to decide which parts of the view should be built by ADT
By following these steps (and further information is given in Eduardo’s blog post) it should not take that much effort to add support for ADT to your own portlets. The one downside to editing and creating templates in your browser is that it does not have the flexibility offered by most IDEs. You will get quite fluent with the editor with a bit of practice, so the pros of not having to deploy your plugin outweigh the cons of the browser-based editor.
The Application Display Templates framework was the one feature in Liferay 6.2 that had me worked up right from the get-go. I can’t wait to get my hands dirty and harness the power it offers to my own custom plugins!