Eventing in Liferay Portlets

感情迁移 提交于 2019-12-06 03:39:53

问题


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:


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?

  • It's a good idea. A common implementation is to use a url Fragment Identifier (hash) to store state in the url. A ready to use JQuery implementation for that is JQuery BBQ

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.


来源:https://stackoverflow.com/questions/8135405/eventing-in-liferay-portlets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!