wood burning stoves 2.0*
The moose likes Portals and Portlets and the fly likes Inter-portlet communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Inter-portlet communication" Watch "Inter-portlet communication" New topic
Author

Inter-portlet communication

Xinsheng Chen
Greenhorn

Joined: May 28, 2008
Posts: 7
I am learning to write portlets using Spring Framework in Liferay. For the same portlet, I can handle the change of UI by embedding a url similar to the following:

<a href="<portlet:renderURL portletMode="view"/>">
View Mode
</a>

However, if I want to call another portlet, how can I specify its url?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Interportlet communication can be done through the APPLICATION_SCOPE of the PortletSession. But the portlets must be in the same war.

Tutorial on Using the PortletSession APPLICATION_SCOPE

It's not a perfect solution, but it's often enough. When portlets are in different wars, a homegrown solution must be used. With IRAD/WebSphere, you can use C2A (Click-2-Action) or PortletServices. Other times a shared database table might be needed.

-Cameron McKenzie
Jonas X. Yuan
author
Ranch Hand

Joined: May 18, 2008
Posts: 108
Hi

In Liferay, there are four possible solutions

AJAX way

The pattern is:
You make an ajax call from one portlet and provide this portlet with
id in another portlet. When you have an answer from the ajax call you update the div with the information you got.

It would be convenient to route the calls through a container object. Whenever, a portlet is added or removed, it needs to register/un-register itself to the container. The container would refer to the portlet through it's id and the reference to the DIV element.

Session variables sharing

Another way is to store variables in the session and make them sharable for portlets. This way you can put stuff into session and display different things based on the information in the session.

Use Liferay portlet url tag

Proprietary portlet url tag that allows you to target one portlet to another (cross-linking).

Page Parameters


Books: Liferay Portal 6.1 Systems Development
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

The AJAX way is very interesting. I'd never thought of that, and I haven't seen that even suggested in this portal forum. Very kewl indeed!

Knowing the DIV tag name in one portlet of another portlet seems like some pretty tight coupling, but probably not that bad if the portlets are packaged in the same war file.

The other concern is that the user can always add and remove portlets from the portal page. Sure stinks when the portlet that is supposed to receive and display the message isn't there.

-Cameron McKenzie
Xinsheng Chen
Greenhorn

Joined: May 28, 2008
Posts: 7
Thank you, guys, for so much input!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inter-portlet communication
 
Similar Threads
Oracle 10g portal.
Portal Deployed;but cant see it.
Replacement for createReturnURI in JSR1 68
How to change the Hello Portlet in Jetspeed2 Demo
Problems developing a new Hello Word�s Portlet for JetSpeed