掲示板

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

12年前 に Mike Harris によって更新されました。

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

Junior Member 投稿: 91 参加年月日: 11/03/28 最新の投稿
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
12年前 に Jitendra Rajput によって更新されました。

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

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
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
12年前 に Amos Fong によって更新されました。

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

Liferay Legend 投稿: 2047 参加年月日: 08/10/07 最新の投稿
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
12年前 に Ravi Kumar Gupta によって更新されました。

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

Liferay Legend 投稿: 1302 参加年月日: 09/06/24 最新の投稿
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.. ??
12年前 に Mike Harris によって更新されました。

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

Junior Member 投稿: 91 参加年月日: 11/03/28 最新の投稿
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.
10年前 に Smilelws2010 lwz によって更新されました。

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

Regular Member 投稿: 160 参加年月日: 10/12/16 最新の投稿
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
10年前 に Smilelws2010 lwz によって更新されました。

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

Regular Member 投稿: 160 参加年月日: 10/12/16 最新の投稿
HI

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

Regards,
Smile