|
Home > Archive > WebSphere Portal Server > April 2006 > Sharing data between portlets
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Sharing data between portlets
|
|
|
| Hi,
Each portlet in a portal gets a separate PortletSession. So this cannot be used for IPC ? Is this right ?
Why can't I use PortletSession or PortletContext to share data between portlets ?
I thought that if I add data to HttpSession in a JSP rendered by one portlet it will be available in another portlet or the JSP rendered by it. It doesn't seem to work.
Can anybody correct these ideas ? If I add two portlets to a portal in RAD then it is deployed as a single web application. Right ? If so then PortletSession can be used to share data. Why doesn't this work ?
Thanks,
Mohan
| |
|
| I create a dynamic web project and included my Portal EAR that contains the two portlets that are trying to share data using the PortletSession. It seems that these two portlets are two web applications. Correct me if I am wrong ?
But I ended up with this error
Virtual Host/WebGroup Not Found : The web group /InterPortletComm/ has not been defined
Thanks,
Mohan
| |
|
| > Hi,
>
> Each portlet in a portal gets a separate
> e PortletSession. So this cannot be used for IPC ? Is
> this right ?
Please, define IPC. What does it mean?
> Why can't I use PortletSession or PortletContext to
> share data between portlets ?
In order to share data between portlets you can use PortletContext. But these portlets must be together in the same portlet application. Anyway, what kind of data are you referring to? Can it be achieved by executing simple getAttribute() and setAttribute
() methods of PortletContext object?
> Can anybody correct these ideas ? If I add two
> portlets to a portal in RAD then it is deployed as a
> single web application. Right ?
Who defines if the portlets will be in only one application or will be separated in two or more web applications is you. You define it, when you create a portlet project in RAD. Each portlet project in RAD represents one web application. An advantage of p
utting two or more portlets in the same project, and therefore, in the same web application, is that you can share data between these portlets, that I suppose is your objective, isn't it? You can share data using, for example, PortletContext.getAttribute(
) and PortletContext.setAttribute() method. There are other ways to share data, of course. But the point is: you only can share if the portlets are together in the same web application. Otherwise, you cannot. Are you aware about this?
> If so then
> PortletSession can be used to share data.
No. Unless you want to share data of the same user who is logged in Portal. If you want to share data between different users in Portal, you have to use PortalContext object.
| |
|
| > Each portlet in a portal gets a separate
> e PortletSession.
I think you are confused about the concept of PortletSession and PortletContext. A PortletSession is related to the logged user of the Portal. In other words, each logged user has a PortletSession object related to him.
PortletContext is related to the portlet application, that can have one or more portlets. Therefore, using a PortletContext object you can share data between portlets of this same portlet application.
Which kind of portlet are you developing? IBM portlet or JSR168 portlet?
| |
|
| It depends on how you deployed your portlets. If the two portlets are deployed in a single web module, the portlets are part of a single web application. If you deployed two different web modules, each containing one portlet, they are running in separat
e applications.
I don't think that answers your original question, though. If you want two portlets to share data pertaining to the user that is currently logged in, you can add attributes to the session in one portlet and pull them out in the other. The data will be k
ept in the session until that user logs out. Once the user logs out, the data will go away. If another user logs in, they won't have access to that other user's data, either.
If, on the other hand, you want two portlets to share data that applies to all users in general, the session won't do what you want.
| |
|
| PortletSession stores data from a session on a single portlet. To store data to be handled by more than one portlet of the same concrete portlet application have to use portletApplicationSettings.
PortletApplicationSettings is used to encapsulate the information pertaining to all concrete portlets\ deployed as part of the same concrete portlet application.
| |
|
| PortletContext shares data between portlets deployed via the same web.xml regardless of concrete porlet application. To share data between portlets from a concrete portlet application you have to use portletapplicationsettings.
| |
|
| Yes. I understand the difference between(assuming the servlet analogy holds good) a PortletContext and a PortletSession. IPC stands for inter-portlet communication. It is the RAD tool that caused this confusion.
It is working now. Thanks everybody.
Actually I was searching for ideas like these
http://e-docs.bea.com/alui/devdoc/d...astlistener.htm
Are you aware of any Java framework that can help ? What is the equivalent of Struts or Plumtree's ALI scripting framework(link above) in the portal world ?
Thanks,
Mohan
| |
|
| click-to-action is a solution to have cooperative portlets having loose coupling.
Read about PropertyBrokerService.
| |
|
| I forgot to say click-to-action don't work with stantard portlets, only with IBM portlets (not JSR 168 potlets).
|
|
|
|
|