Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Danny Stevens
Finding preferences for all portlet instances
14 de Setembro de 2011 23:13
Resposta

Danny Stevens

Ranking: New Member

Mensagens: 20

Data de entrada: 14 de Setembro de 2011

Mensagens recentes

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?
Danny Stevens
RE: Finding preferences for all portlet instances
14 de Setembro de 2011 23:17
Resposta

Danny Stevens

Ranking: New Member

Mensagens: 20

Data de entrada: 14 de Setembro de 2011

Mensagens recentes

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.

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


then I just read the preferences in.
Victor Zorin
RE: Finding preferences for all portlet instances
14 de Setembro de 2011 23:29
Resposta

Victor Zorin

Ranking: Liferay Legend

Mensagens: 1178

Data de entrada: 14 de Abril de 2008

Mensagens recentes

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();
...
Danny Stevens
RE: Finding preferences for all portlet instances
14 de Setembro de 2011 23:40
Resposta

Danny Stevens

Ranking: New Member

Mensagens: 20

Data de entrada: 14 de Setembro de 2011

Mensagens recentes

Thanks Victor,

that is exactly what I was looking for.

cheers

Danny