Eduard Grinchenko
Eduard Grinchenko

Reputation: 524

How to configure portlet in liferay 6.1 programmatically?

How to set specific options of different portlets programmatically? For example how to set view in "Web Content Display" portlet to specific JournalArticle.

Upvotes: 2

Views: 2199

Answers (1)

rp.
rp.

Reputation: 3465

This one might be a bit difficult because there will be some discovery involved. First you'll need to figure out which preference key you'd like to over write. The difficult lies that the developer can use any key for example some of Liferay's are portlet-setup-show-borders.

But to set a Web Content Display, you can use something like:

PortletPreferences portletSetup =
    PortletPreferencesFactoryUtil.getLayoutPortletSetup(
        layout, portletId);

portletSetup.setValue("groupId", String.valueOf(layout.getGroupId()));
portletSetup.setValue("articleId", articleId);

portletSetup.store();

Upvotes: 4

Related Questions