Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eventing in Liferay Portlets

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?

like image 303
Ravi Avatar asked Nov 13 '22 14:11

Ravi


1 Answers

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.
like image 183
Tony Rad Avatar answered Dec 21 '22 18:12

Tony Rad