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
Mike Harris
How to find a portlet based on "it's instance id"?
8 de Março de 2012 14:24
Resposta

Mike Harris

Ranking: Junior Member

Mensagens: 86

Data de entrada: 28 de Março de 2011

Mensagens recentes

I have this portlet "id" :
101_INSTANCE_uzfgEVROg3RH

that came from this code :

1UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();
2String defaultAssetPublisherPortletId = typeSettingsProperties.getProperty(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);


(It's the default asset publisher of a Layout).
Question is : How can I get the Portlet object based on that id?
Jitendra Rajput
RE: How to find a portlet based on "it's instance id"?
8 de Março de 2012 22:06
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 575

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

Not sure ..but this instance Id is changed when you remove your portlet from page and again place.

Not sure how to do with Instanciable portlet but it would be easy if you make your portlet non-instanciable
Amos Fong
RE: How to find a portlet based on "it's instance id"?
8 de Março de 2012 23:24
Resposta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1817

Data de entrada: 7 de Outubro de 2008

Mensagens recentes

Hi Mike,

You can use this:

1PortletLocalServiceUtil.getPortletById(long companyId, String portletId)


If you look at the source, it uses this to get the root portletId:

1String rootPortletId = PortletConstants.getRootPortletId(portletId);
Ravi Kumar Gupta
RE: How to find a portlet based on "it's instance id"?
8 de Março de 2012 23:31
Resposta

Ravi Kumar Gupta

Ranking: Liferay Legend

Mensagens: 1041

Data de entrada: 23 de Junho de 2009

Mensagens recentes

In this portlet id is just 101 rest is instance id. Instance id is useful when some preferences are set.

I wonder what you are going to do with that portlet object. If you need some properties like description, title, prefs etc of a portlet you can get using PortalUtil.getPortletXXX() methods..

Can you please explain some scenarios.. ??
Mike Harris
RE: How to find a portlet based on "it's instance id"?
9 de Março de 2012 05:55
Resposta

Mike Harris

Ranking: Junior Member

Mensagens: 86

Data de entrada: 28 de Março de 2011

Mensagens recentes

Sure. The scenario is that I'm making a custom portlet that finds the default WebContent associated to child pages of the page where it belongs.
Then it displays some informations coming from that Web Content (it's a custom structure, so we have a "summary" field and other stuff)
The default WebContent is in fact the WebContent associated to the default asset publisher of the page. If there's no default asset publisher or if there are more than 1 WebContent associated to the asset publisher, then it just ignores it.
Smilelws2010 lwz
RE: How to find a portlet based on "it's instance id"?
10 de Maio de 2013 08:05
Resposta

Smilelws2010 lwz

Ranking: Regular Member

Mensagens: 129

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

Hi Ravi,

I have a class where I have the list of all the portlet-instance-ids.

ANd each instance has a preference value set in it. Is it possible to read the preference object value for all those portlets using instance ids?

Thanks and much appreciate the help.

Any insight will be very helpful

Thanks
Smile
Smilelws2010 lwz
RE: How to find a portlet based on "it's instance id"?
10 de Maio de 2013 08:05
Resposta

Smilelws2010 lwz

Ranking: Regular Member

Mensagens: 129

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

HI

I could figure this out. You can use the class, PortletPreferencesLocalServiceUtil to get the preference object.

Regards,
Smile