掲示板

perform task as soon as we add liferay portlet on page

thumbnail
11年前 に Vishal Panchal によって更新されました。

perform task as soon as we add liferay portlet on page

Expert 投稿: 289 参加年月日: 12/05/20 最新の投稿
Hi All,

We have a requirement when Portlet is added to a page, we want particular initialization always be done.

So do we have any method which we can override and write list of tasks which can be applied as soon as the portlet is added on the page.

I tried by overriding init() method but it called when we Deploy the portlet but not when we add portlet on page.

on other side render() and doView() which are being called multiple time which is not the solution.

Please provide your suggestions.

Thanks,
Vishal
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: perform task as soon as we add liferay portlet on page

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
I would put the logic in the render() method...

Use a portlet pref to determine if the desired initialization was completed. If not, complete the initialization and set the portlet pref so it doesn't re-initialize.

Since portlet prefs are unique for each portlet placed on the page, your logic would be invoked every time the portlet was placed on a page (each one would invoke the initialization on it's own).

If you're looking for a global sort of parameter (only one init regardless of how many portlets are placed), you'll have to back this w/ a database poll of some kind. Potential here would be to use the Expando bridge from the corresponding portlet entity from Liferay so you wouldn't have to create tables, entities, etc.
thumbnail
11年前 に Vishal Panchal によって更新されました。

RE: perform task as soon as we add liferay portlet on page

Expert 投稿: 289 参加年月日: 12/05/20 最新の投稿
Hay David,

Thank you for your valuable inputs.
It looks like portlet prefs is the best way to achieve this(preventing the render method to be called repeatedly).

Let me try it out.

Thanks,
Vishal