RE: Reading portlet preference in Scheduler of the portlet

Liferay Question, modified 14 Years ago.
Hi,

Can I get portletPreference of my portlet in the scheduler of the same portlet.

Regards,
Liferay Questions
thumbnail
Shagul Khajamohideen, modified 14 Years ago. Liferay Master Posts: 758 Join Date: 9/27/07 Recent Posts
Liferay Question:
Hi,

Can I get portletPreference of my portlet in the scheduler of the same portlet.

Regards,
Liferay Questions



As you may know , portlet preferences belong to the portlet (portletId) in a page (plid). If the portlet is instanceable then the portletId will be that of the portlet instance id. Portlet preferences are stored in the database and com.liferay.portal.util.PrefsPropsUtil.java can be used as an example on how to retrieve those preferences using the PortletPreferencesLocalServiceUtil.
Liferay Question, modified 14 Years ago.
Hi Shagul,

Thanks for your reply.
Yes the only problem i find now is how to find the plid of a portlet in a scheduler, because all i have there is a companyId.

Regards,
Liferay Questions.
Andrew Millband, modified 13 Years ago. New Member Post: 1 Join Date: 11/22/11 Recent Posts
Clark - did you ever find a solution to this? I have a similar use case, and before I post a new question I'm hoping you might've found an answer emoticon
Amos Fong, modified 6 Years ago. Junior Member Posts: 40 Join Date: 12/16/15 Recent Posts
Hi Andrew,
Did you get solution for this case?emoticon​​​​​​​
thumbnail
Josef Šustáček, modified 13 Years ago. New Member Posts: 22 Join Date: 10/5/09 Recent Posts
Hi,

I used portlet schedulers back in 5.2.3 and if it wasn't changed, you don't have access to such objects. The scheduler is run only once, not per portlet instance, right?

If I remember, the scheduler is defined for the portlet as a whole (you define one scheduler class in liferay-portlet.xml per portlet), that means one scheduler for all instances of the portlet in the whole portal, on all pages.

I'm not sure how this works with more companies in portal, but I assume this is not your case and you have only one company.

If you want to do some portlet preferences update for one portlet instance located on some page, you have to define plid (page's id, e.g. 10520) and portletId (instance id, e.g. _mybusinessapplicationportlet_WAR_myportlet_INSTANCE_FqL4) in some properties file and read this file from scheduler. Then you can load portlet preferences of such portlet instance via:


Layout layout = LayoutLocalServiceUtil.getLayout(plid);

javax.portlet.PortletPreferences prefs = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId);
Abhay Chaware, modified 11 Years ago. Junior Member Posts: 36 Join Date: 7/17/13 Recent Posts
Hello ..
Sorry to open up this old thread, but in my case I actually have multiple companies ( portal instances ) and need to run the same scheduler job on all the instances. I have a thread posted here. Any pointers ?

Thanks
Abhay