Sharing data between portlets
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > Sharing data between portlets




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

Hi,

Each portlet in a portal gets a separate PortletSession. So this cannot be u
sed for IPC ? Is this right ?

Why can't I use PortletSession or PortletContext to share data between portl
ets ?

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 t
hen it is deployed as a single web application. Right ? If so then PortletSe
ssion can be used to share data. Why doesn't this work ?

Thanks,
Mohan





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

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 seem
s 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 b
een defined


Thanks,
Mohan





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

> 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 thes
e portlets must be together in the same portlet application. Anyway, what ki
nd of data are you referring to? Can it be achieved by executing simple getA
ttribute() 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 separ
ated 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 app
lication. 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 s
uppose is your objective, isn't it? You can share data using, for example, P
ortletContext.getAttribute(
) and PortletContext.setAttribute() method. There are other ways to share da
ta, of course. But the point is: you only can share if the portlets are toge
ther 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.





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

> Each portlet in a portal gets a separate
> e PortletSession.

I think you are confused about the concept of PortletSession and PortletCont
ext. 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 m
ore portlets. Therefore, using a PortletContext object you can share data be
tween portlets of this same portlet application.


Which kind of portlet are you developing? IBM portlet or JSR168 portlet?





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

It depends on how you deployed your portlets.  If the two portlets are deplo
yed in a single web module, the portlets are part of a single web applicatio
n.  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, y
ou 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 da
ta will go away.  If another user logs in, they won't have access to that ot
her user's data, either.

If, on the other hand, you want two portlets to share data that applies to a
ll users in general, the session won't do what you want.





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

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 applic
ation have to use portletApplicationSettings.

PortletApplicationSettings is used to encapsulate the information pertaining
 to all concrete portlets\ deployed as part of the same concrete portlet app
lication.






[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

PortletContext shares data between portlets deployed via the same web.xml re
gardless of concrete porlet application. To share data between portlets from
 a concrete portlet application you have to use portletapplicationsettings.






[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

Yes. I understand the difference between(assuming the servlet analogy holds 
good) a PortletContext and a PortletSession. IPC stands for inter-portlet co
mmunication. 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...ner.
htm

Are you aware of any Java framework that can help ? What is the equivalent o
f Struts or Plumtree's ALI scripting framework(link above) in the portal wor
ld ?

Thanks,
Mohan





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

click-to-action is a solution to have cooperative portlets having loose coup
ling.

Read about PropertyBrokerService.





[ Post a follow-up to this message ]



    Re: Sharing data between portlets  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 01:07 PM

I forgot to say click-to-action don't work with stantard portlets, only with
 IBM portlets (not JSR 168 potlets).





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 02:44 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register