9 Replies Latest reply on Jun 21, 2006 6:45 AM by tuomas_kiviaho

    Share data between portlets for each user session

    endremr

      Hi!

      I'm pretty new to Seam, so maybe this is an easy question, but I haven't found out how to solve it.

      I have a Seam portlet application deployed i JBoss Portal, that defines a page with two portlets that should share some information for the user visiting the page.

      I have tried to share data with the ApplicationContext. This works but the data is available for all users. But when I try to use the SessionContext instead, the data is only available in the portlet where I set the attribute. Shouldn't it be available for the whole user session; both portlets?

      Do I have to use the "javax.portlet.PortletSession" with application scope instead? If so, do anybody have an example how to access it from Seam? I miss some documentation here...

      I'm using JBoss 4.0.4.GA, Seam 1.0.0.GA and JBoss Portal 2.4.0-BETA1.

      Thanks for advice :)

        • 1. Re: Share data between portlets for each user session
          gavin.king

          No, portlet session are portlet-local. There is no standard way to do inter-portlet communication in the portlet spec, but most products provide some proprietary APIs.

          It is something I need to look into more closely with Roy.

          • 2. Re: Share data between portlets for each user session
            endremr

            It that true for Seam applications? I thought that Seam was a bit close to JBoss Portal. I have read different places that JBoss Portal supports interportel communication if they are build into the same portlet application.

            Quote:
            "Any object stored in the session using the APPLICATION_SCOPE is available to any other portlet that belongs to the same portlet application and that handles a request identified as being part of the same session."

            From page:
            http://jboss.org/index.html?module=bb&op=viewtopic&t=66156&view=previous

            Doesn't seam support this? Then my question is how I can access the PortletSession from Seam. Is that possible?

            Thanks again! :)

            • 3. Re: Share data between portlets for each user session
              endremr

              Sorry for answering myself!

              Now I've found a way to solve my problem. It works when I use the PortletSession and the APPLICATION_SCOPE. Now I have also found the way to get the PortletSession from Seam:

              ((javax.portlet.PortletRequest) getFacesContext().getExternalContext().getRequest()).getPortletSession();

              • 4. Re: Share data between portlets for each user session
                gavin.king

                I have a roadmap item to look at integrating JBoss Portal's IPC stuff with Seam. But I have not done any of the research I need to do to understand this stuff properly yet.

                • 5. Re: Share data between portlets for each user session
                  theute

                  Yes in Portal per the spec there are 2 scopes of session, portlet and application scope.
                  Currently in Seam we only support Portlet scope.

                  IPC is different, it doesn't have any context, it just trigger events that other portlets are listening to.

                  • 6. Re: Share data between portlets for each user session
                    gavin.king

                    Originally, I had actually planned a PORTLET_SESSION scope distinct from the SESSION scope. But then from Roy I got the impression that use of the global session scope was considered a Bad Thing. Perhaps we need to revisit that discussion.

                    On the IPC stuff, it is an event architecture, and so it is ripe for abstraction by Seam.

                    • 7. Re: Share data between portlets for each user session
                      theute

                      SESSION scope is misused to do IPC in a standard way (It's the only way that would work on any JSR168 portlet container).
                      There is no real logic for application session scope.

                      • 8. Re: Share data between portlets for each user session
                        gavin.king

                        Well, I guess I'm just not quite convinced that this is always a misuse...

                        • 9. Re: Share data between portlets for each user session
                          tuomas_kiviaho

                          I thought I'd seen a portlet scope, that is PortletSession.APPLICATION_SCOPE reservation in earlier seam documentations and wondered what has happened when the time came for it to be used.

                          I'd rather be "misusing" session with Seam annotations than doing it "by-the-book" without Seam support. IPC of JBoss Portal is quite compact solution - one of the best in my opinion - in it's simplicity but not a solution that can be used with other portal containers. Also there is that one-to-one relationship between portlets restriction.

                          I hope that this scope will come as part of Seam although it's directly supported by JSF and causes tight coupling with portlet api since I don't think new contexts below conversation can plugged in just like that allowing them to be truly optional.

                          Mimicking IPC with Seams remote JMS capability seems to be an option, but I see that it may change radically in the future.

                          One hack that came into my mind is to make ExternalContext session dynamically selectable. This only shifts problems to other areas even when not needing instance spesific sessions, since somehow JSF needs to transfer the state over portlet's processAction to renderRequest. This may even be against JSF spec and it doesn't concern the Seam implementation. Note that it requires access to the JSF binaries. I wouldn't go this way myself all the way, but this could propably be used to some sort of prototyping due to the benefit gained from Seam annotations that avoid completely the use of
                          ((javax.portlet.PortletRequest) getFacesContext().getExternalContext().getRequest()).getPortletSession(). Knowledge of how MyFaces PortletExternalContext works is needed.