掲示板

Finding preferences for all portlet instances

thumbnail
12年前 に Danny Stevens によって更新されました。

Finding preferences for all portlet instances

New Member 投稿: 20 参加年月日: 11/09/15 最新の投稿
I have a site with multiple pages each with multiple instances of a portlet on the page, each instance with its own preference settings.

I have a scheduled task executing that needs to find the preferences for each instance on each page and do some work with that information.

I have searched all over the wikies and can't find what I'm looking for. Anyone able to help?
thumbnail
12年前 に Danny Stevens によって更新されました。

RE: Finding preferences for all portlet instances

New Member 投稿: 20 参加年月日: 11/09/15 最新の投稿
I am currently considering reading the database. It would be better to use some higher level liferay function though.

This query appears to do the trick in SQL.


select * from portlet p, portletpreferences pp
where p.portletid=pp.portletid
and (p.portletid like '%cms%' or p.portletid like '%data%')
and p.active_=true



then I just read the preferences in.
thumbnail
12年前 に Victor Zorin によって更新されました。

RE: Finding preferences for all portlet instances (回答)

Liferay Legend 投稿: 1228 参加年月日: 08/04/14 最新の投稿
Do not do database, see extract from our code below:

import com.liferay.portal.service.PortletPreferencesLocalServiceUtil;
import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.myoffice24x7.common.portlet.BaseConfigurableItem;
...
int totalCount = PortletPreferencesLocalServiceUtil
.getPortletPreferencesesCount();
...
java.util.List<com.liferay.portal.model.PortletPreferences> list = PortletPreferencesLocalServiceUtil
.getPortletPreferenceses(currentIndex, toIndex);

java.util.Iterator<com.liferay.portal.model.PortletPreferences> it = list
.iterator();
while (it.hasNext()) {
com.liferay.portal.model.PortletPreferences pref = it.next();
if (pref.getPortletId().startsWith(config.getPortletName())) {
String settings = LayoutLocalServiceUtil.getLayout(pref.getPlid()).getTypeSettings();
...
thumbnail
12年前 に Danny Stevens によって更新されました。

RE: Finding preferences for all portlet instances

New Member 投稿: 20 参加年月日: 11/09/15 最新の投稿
Thanks Victor,

that is exactly what I was looking for.

cheers

Danny