• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Application Scope Session in IBM portal server

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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,
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could any one please help me!

Thanks,
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
((PortletRequest)request).getPortletSession().setAttribute(key, value, scope);

Well, the getPortletSession() would imply that you have set the attribute in the Session scope, NOT the application scope!

You might find this tutorial on Portlet config objects interesting. It might help you out:

Understanding Portlet Configuration Objects - PortletContext, PortletConfig, Application Scope, PortletSession

-Cameron McKenzie

-Cameron McKenzie
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
McKenzie,

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.

Thanks,
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

-Cameron McKenzie
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cameron,

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?
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

-Cameron McKenzie
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic