Foren

Meaning of APPLICATION SCOPE

Luca kk, geändert vor 12 Jahren.

Meaning of APPLICATION SCOPE

Expert Beiträge: 284 Beitrittsdatum: 07.12.10 Neueste Beiträge
Hi all,
I have created two portlets as distinct projects (Web Application) by Net Beans.
I deployed those in Liferay and i can add to portal as "User_Portlets": in this menu
there are the two created portlets.
If I use "PortletSession.APPLICATION_SCOPE", can I exchange session attributes
between the two portlets?
Or have I do only one project into Net Beans which contains the two portlets?
Thanks in advance.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: Meaning of APPLICATION SCOPE

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
By specification, separate WARs cannot cross their servlet session boundaries. This is intended, and prevents one WAR from corrupting or polluting the session of another WAR.

Portlets, by specification, have similar boundaries for similar reasons.

Portlets in the same WAR will have different portlet sessions, yet they share the same servlet session scope and offered a less than optimal (but still effective) way to share data between portlets.

Rather than pursuing this path (which you may not be aware is frought with hazard), read up on the IPC mechanisms in the JSR 286 specification that would cleanly allow you to implement IPC mechanisms.
Luca kk, geändert vor 12 Jahren.

RE: Meaning of APPLICATION SCOPE

Expert Beiträge: 284 Beitrittsdatum: 07.12.10 Neueste Beiträge
Hi David,
thanks for the response.
I have already read the IPC mechanisms but i don't understand
how to deploy two portlets to make communication themselves.
To deploy them in the same war I have to create a only file
"portlet.xml", is it right?
Or have I edit others files?
Thanks,
Luca
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: Meaning of APPLICATION SCOPE

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
To create a single WAR, you have to merge the separate projects into a single project. Your portlet.xml, liferay-portlet.xml, liferay-display.xml, etc. would all be modified to have two portlets rather than just one.

IPC does not require them to be in the same project, especially if you're using the event mechanism. One portlet will indicate it subscribes to certain events, and another portlet will indicate that it publishes certain events. There are no boundary and/or deployment issues that come into play here....