This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I've written a portlet which displays a directory structure that the user can navigate to access files. This is working fine. Putting it simply the directory structure and current state, ie which directory the user has navigated to, is stored in a TreeMap which is stored in the PortletSession.
The requirement is for the user to be able to view two directory structures so I have duplicated the portlet, so I have DirectoryPortlet1 and DirectoryPortlet2. I have each Portlet on a different page.
However, the problem is that if I navigate to a directory on one page, then when I look the other page then then the navigational state is the same. It appears that although I have two portlets they are sharing the same PortletSession. How do I can have a separate session for each portlet?
I'm wondering if anything is being put in a common scope, or context scope. Two different users don't get the same duplication, right? Like if you opened up an IE and Firefox browser, logged in both with the same username, the two browsers would be different, right?
There's no way you're using APPLICATION_SCOPE for the session data, instead of session scope?
It certainly seems like there's a central spot from which the client is reading data.
Joined: Jul 13, 2005
I'm now explicitly using PortletScope, just to be on the safe side and it has made no difference. The behaviour is the same if I logon in another browser
I'm using a singleton to build the initial treemap. When the portlet calls the singleton it gets a copy of the TreeMap. The portlet copy of the TreeMap is kept in the PortletSession. The portlet initialises a view bean with data from the TreeMap, the view bean is added to the PortletSession.
Joined: Jul 13, 2005
Woops, it was me not cloning objects properly
Cameron Wallace McKenzie
author and cow tipper