Eventing in Liferay Portlets

2019-04-09 01:05发布

In any portlet application, if the same page containing a portlet is opened in two browser tabs, how is the event in the first page distinguished from the second page?

I want to assign a unique Id for each event, store it and append it to the URL so that the link can be shared.

Can someone provide their thoughts on this ?

Also, if the page URL is opened on other computer the data shown on the page is the same as the data seen on the first computer. This is being set globally.

How can I eliminate this?

1条回答
smile是对你的礼貌
2楼-- · 2019-04-09 01:55

JSR-286 (latest Java Portlet Specification) defines Server Side and Client side Inter Portlet Communication (IPC). For Liferay implementation they are well described here and here.

First question:

In any portlet application, if the same page containing a portlet is opened in two browser tabs, how is the event in the first page distinguished from the second page?

  • Client Side IPC: it is NOT possible to fire and listen a Liferay javascript event between two different browser tabs. So they will be automatically distinguished. However you may use a cookie based approach to implement it (look here if interested)
  • Server Side IPC: it is possible to share data (server side) between different client windows using server side IPC (see the above Liferay's links for examples)
Second question:

I want to assign a unique Id for each event, store it and append it to the URL so that the link can be shared. Can someone provide their thoughts on this?

Also, if the page URL is opened on other computer the data shown on the page is the same as the data seen on the first computer. This is being set globally. How can I eliminate this?

  • I'm assuming you're talking of the same Liferay User account (otherwise it is possible to scope data by role, user, group, user group or organization in Liferay). To differentiate data among different computers for the same user, you can store and pass back to the portal cookie(s) with state information about the client computer. See here for how to set cookie in Liferay.
查看更多
登录 后发表回答