Forums de discussion

How to find a portlet based on "it's instance id"?

Mike Harris, modifié il y a 12 années.

How to find a portlet based on "it's instance id"?

Junior Member Publications: 91 Date d'inscription: 28/03/11 Publications récentes
I have this portlet "id" :
101_INSTANCE_uzfgEVROg3RH

that came from this code :

UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();
String 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?
thumbnail
Jitendra Rajput, modifié il y a 12 années.

RE: How to find a portlet based on "it's instance id"?

Liferay Master Publications: 875 Date d'inscription: 07/01/11 Publications récentes
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
thumbnail
Amos Fong, modifié il y a 12 années.

RE: How to find a portlet based on "it's instance id"?

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Hi Mike,

You can use this:

PortletLocalServiceUtil.getPortletById(long companyId, String portletId)


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

String rootPortletId = PortletConstants.getRootPortletId(portletId);
thumbnail
Ravi Kumar Gupta, modifié il y a 12 années.

RE: How to find a portlet based on "it's instance id"?

Liferay Legend Publications: 1302 Date d'inscription: 24/06/09 Publications récentes
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, modifié il y a 12 années.

RE: How to find a portlet based on "it's instance id"?

Junior Member Publications: 91 Date d'inscription: 28/03/11 Publications récentes
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, modifié il y a 10 années.

RE: How to find a portlet based on "it's instance id"?

Regular Member Publications: 160 Date d'inscription: 16/12/10 Publications récentes
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, modifié il y a 10 années.

RE: How to find a portlet based on "it's instance id"?

Regular Member Publications: 160 Date d'inscription: 16/12/10 Publications récentes
HI

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

Regards,
Smile