What does application scope really mean? I have a application in which i have three portlets. I want to access a variable thru all the portlets so i set that variable in application scope like
when i log off portal and re-login i couldn't find that variable in the session. I want the variable to be in the session even when the user logs off portal server. could any one take me in the right direction.
Thanks for you reply. I am putting the variable in the application scope by specifying scope as PortletSession.APPLICATION_SCOPE. Below is the code snippet:
I login to portal with portal admin user name/pwd. I have no problem accessing this variable from different portlets. But when i log off portal admin and re-login the application scope variable is null. Is this the desired behavior.
HI, You are not storing the object in appliaction scope, instead you are storing in session scope. So the object you stored will be available only till the session is alive. Once the session is deactivated, the object is no longer available. The session will be deactivated once you are logged off. Hence when you are retreiving back after relogin , you are getting null
I think application scope in this case means that the session attributes in the PortletSession will be available to other portlets running in the portal at the same time. At the end of the session though, they are released.
Hope this helps. [ July 08, 2008: Message edited by: Kirk Schuller ]
Cameron Wallace McKenzie
author and cow tipper
other portlets running in the portal at the same time
Regardless of the scope, portlets from separate war files will never be able to share PortletSession data. The APPLICATION_SCOPE of the PortletSession only mitigates the sharing of data between portlets packaged within a common web application archive.
For true global information sharing, you need to create some kind of Portlet Service, Web Service, or commonly accessible database table.
Please clarify me this. In srikanth's problem, suppose the data to be persisted is of type String only, then can this problem be solved by storing the values in PortletPreferences object instead of storing in database?
Well, remember, PortletPreferences are stored permanently, whereas the session data disappears after the user logs out. Also, the user must be in the edit mode of the portlet to change or update the PortletPreferences object. That's probably too restrictive given the scenario.