Tip of the Day - Portlet Setup Archive

Creating configurable portlets allow site administrators to customize the behaviour of the portlet the way they want to. The core feature set can be expanded dynamically by changing the portlet preferences. You could, for instance, change the email address where customer feedback is delivered, change the display styles of asset publishers or even disable some features if needed. Using portlet configuration services offered by Liferay should be in the toolbox of every Liferay Developer.

In a recent discussion, my colleague here at Ambientia told me about this nice little feature called portlet setup archive. By using the archive you can save the portlet’s preferences and restore them to different instances of the same portlet. This was no news to me, I had done that before, for example when configuring asset publisher, experimenting with some advanced setup, always keeping the original as a backup.

Portlet configuration view

Simple Liferay configuration view to enable basic configuration of portlet. Note the Archive/Restore Setup feature in the right-hand corner

What I did not know was that when you archive the portlet setup, you get the preconfigured versions of the portlet also to the Liferay’s Add menu, under the application itself. This is extremely helpful in cases where you’d want to use the same setup in different pages. You do not need to restore the archived setup manually after adding the portlet to your page, you can add the configured portlet directly from the add menu.

And what’s even more awesome is that the archive feature does not limit itself to Liferay core portlets only. If you use portlet preferences in your own custom portlets, it is just as easy to archive the setup and add the preconfigured portlets to any page you want to. It needs no extra configuration, the link is added automatically to the user interface. Talk about a nice feature, eh?

Preconfigured portlet in the add menu
Porlet setup saved with the name Hello Liferay - now in the add menu!
Internally Liferay uses portlet preferences to save the modifications made through look & feel menu as well. This means that not only can you save the preferences which alter the way the portlets behave, you can also save the setup on how the certain portlet setup should look like. Although while testing the feature I noticed a minor flaw where you need to refresh the page before the look & feel setup is applied, even when adding the portlet through the add menu. No big deal I’d say, but got me confused for a moment. One more thing worth noting is that the archive is site specific - and it does not archive the portlet permissions! Still a good way to create some templates for greater ease of use of your portal.

Portlet added and ready to go

Finally - preconfigured portlet added to page, just under the default. Notice the title and background color altered through Look & Feel - still saved! 

 

0