简体   繁体   中英

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.

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM