views:

830

answers:

2

I am writing my first portlet based application (for liferay, but the solution should be container agnostic) and I am wondering how people solve to provide links to the user that "lead" to different portlets (maybe on different "pages" in the portal).

While you can easily have different view modes inside your portlet, how can you link to another portlet and (maybe) also pass parameters along?

I am not talking about plain communication between portlets, it's the real pageflow that interests me.

Example: You have page A with a portlet that displays a list of news items. Then you have page B that is in the way configured I'd like a single the news item to be shown (for example different portlets around it)

Is there a generic solution to link to page B and say to the news-Detail-Portlet that it should show item XYZ?

The quick and dirty solution would be to configure the target link via edit mode of the news-list-portlet. But this has several disadvantages: - complex portlets may have several target URLs which leads to massive configuration efforts for the portal admin - the urls may not follow a scheme that allows simple parameter injection

I have a solution in mind, but this would require massive efforts and maybe changes in the targeted portlets, which is not always possible if you use 3rd party portlets.

My solution would look like this: (draft!)

Portlets register at a central service with their portlet IDs and when a portlet wants to link to a portlet it can do a lookup based on a symbolic name. This would ease the pain for the admin, because it is possible to "auto discover" portlets. The service may also provide a UI to wire portlets based on source and target portlet.

The URL generation for portlets that can be changes may be solved via service call to the portlet that generates the URL as a whole with injected parameters and returns it. For portlets that you can't change you have to append the parameters and hope that it works. :-/

Any suggestions? Are there simpler solutions? existing solutions?

Thanks!

Patrick

A: 

For JSR 286 specification it is possible to use events for inter-portlet communication. For the older JSR 168 there isn't an endorsed way to do so. If you find a way that works for you, then use it.

There is an old book given away for free from Manning (registration required). You can find some ideas there.

kgiannakakis
As I wrote the communication is not the problem, I may have to switch to another page which is the main problem.
Patrick Cornelissen
And I may not have the chance to use events when the targetted portlet is not written by me
Patrick Cornelissen
+1  A: 

As far as I know Portlet Specification doesn't cover this. So there is no portable solution. For Liferay you can always use theirs custom tag library which aims exactly this issue. There is similar mechanism for Websphere Portal.

Something can be found here and here

Generally I would try to avoid this and use standard IPC mechanism(Public Render Parameters or Events)

Jaromir Hamala
Thanks, so it looks like I have to write something on my own that uses an abstraction.
Patrick Cornelissen