← Back to front page

The Greatest Feature of Liferay 6.2 – Application Display Templates

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.

Application Display Template Listing

ADT supports seven different Liferay portlets out of the box

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.

Four step program to add ADT support to your own plugin

With four simple steps you can implement ADT in your own plugin as well

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!

8 Responses to “The Greatest Feature of Liferay 6.2 – Application Display Templates”

  1. Henri Sora

    Thanks, Lauri! Please provide a real life example how the feature helps when doing web applications?

    Reply
  2. Lauri Hiltunen

    The main advantage comes from avoiding the deployment of the plugin. I used Asset Publisher as an example (you’d need to build a hook), but as hooks are very simple to create, the real candy lies in your own plugins. If you have a massive portlet, you want to deploy it to production as seldom as possible. And I wouldn’t want to deploy dozens of portlets residing in a portlet-app just to edit one single view of one single portlet. Had you used ADT on the part you’d want to modify, you can avoid the deployment process and the possibility that something goes wrong with it.

    And provided you’d have the permissions to edit views, you can do it on the go, without access to source code or your IDE. As a real life example, you could create a quick fix from the airport or a train, even if you don’t have your own equipment at hand. Just log in, edit the template (or add a new one) and publish the changes.

    Reply
  3. Henri Sora

    To be honest your quick fix from the airport mentality sounds a bit scary… You know, we have GIT and systems in place…

    Reply
    • Lauri Hiltunen

      With great power comes great responsibility. The processes of handling the version control of ADTs is a separate issue, but Liferay offers you export and import functionalities with these so at least you have the tools for developing the flow of work with the framework. Also you can import the script as a file if needed, the framework itself is really flexible. And as a side note, if you can import them from the file, I bet you could create a start-up action of some sort to insert your default templates to your service with the first deploy. Won’t guarantee that though, haven’t tried it.

      Reply
    • Lauri Hiltunen

      ADTs are designed to alter the views and functionality of portlet plugins so I think you’re correct.

      Reply
  4. Traolly Xiong

    Can you add functionality to ADTs as well? Or is just the display (look / feel)?

    Reply
    • Lauri Hiltunen

      It’s quite easy to add some new functionality to your ADTs for instance by using simple javascript tricks. So the answer is yes, you can add and alter functionality of your plugins with ADTs.

      Reply

Leave a Reply

  • (will not be published)

Time limit is exhausted. Please reload CAPTCHA.

Please, leave us a message and we'll contact you.
You can also contact our Service Desk by phone +358 290 010 500 or email servicedesk@ambientia.fi.