-
1. Re: How to set and get Portal session
cry4dawn Oct 16, 2007 8:13 AM (in response to saigon_man)request.getPortletSession().setAttribute("xxx", xxx, PortletSession.APPLICATION_SCOPE);
i really advise against it though. as the idea is that portlets are spoused to be independent units. -
2. Re: How to set and get Portal session
saigon_man Oct 17, 2007 9:24 AM (in response to saigon_man)Hi,
Thanks for the response. The solution you provided only works with portlets within a portal project. If I have another portlet project deployed in jboss server (hot deploy) then this won't work (at least for me)
What I would really like to find out is how to distribute a value/object to all of the portlets deployed within the portal (they can be hot deployed, meaning that they are seperate portlet projects)
For example, I have a string value say String str = "my value". How do I distribute this value to all portlets from the portal scope when the portlets need this value without having the portlets to connect to database to get this value?
Thanks,
SGM -
3. Re: How to set and get Portal session
cry4dawn Oct 17, 2007 5:45 PM (in response to saigon_man)well i dont think its just a portlet problem then. if you deploy 2 wars warA can not see Warb's session without doing some kind of call back. there is always application scope, but thats worse then using the session scope.
that said you could probably create a singelton class to hold the values, shove it into the application scope and have you portlets grab it from there.
i personally would put all the portlets that need to share the same session info into one war and let them all deploy together. on our current project we dont even use session scoped jsf beans, we pass it all along the request, or make a call to the db using request.getRemoteUser() as the parameter to the stored procedure. -
4. Re: How to set and get Portal session
swisst Oct 17, 2007 6:40 PM (in response to saigon_man)Basically you want to cache DB retrievals because you don't want to do them again?
If so, it sounds like a job for your persistence framework (like caching in hibernate).
Or you could do your own caching with something like JCS --> http://jakarta.apache.org/jcs/. They support many different types of caches, even caches for a scaled environment. -
5. Re: How to set and get Portal session
saigon_man Oct 18, 2007 2:21 PM (in response to saigon_man)Thanks for your responses. The string value is just one of the things we want to pass to the portlets. I wonder if you have done anything to user's roles retrieving? That means that if you have a login page in the portal, after you log in, Jboss knows how to map that user's role to appropriate portlets. I wonder if JBoss ever exposes that role throughout its scope? If it does, do you know the name of that variable? (like PortletSession.APPLICATION_SCOPE) or is there a way to get the user's role without doing a JNDI lookup through Hibernate to the database to get the role?
Thanks,
SGM -
6. Re: How to set and get Portal session
cry4dawn Oct 18, 2007 5:47 PM (in response to saigon_man)their are a few things in http request for that.
isUserInRole("String"); which returns a boolean or
getUserPrincipal() which returns a Principle -
7. Re: How to set and get Portal session
saigon_man Oct 19, 2007 10:53 AM (in response to saigon_man)Hi,
The isUserInRole("String") always returns false for the default roles in jboss which are "Admin" and "Users" or whatever default roles comes with jboss.
I don't know if there are any configurations that I should do first. Searching in this forum for this question is hard since there are lots of question related to this method. I read the documentation and saw there is an API for portal session called PortalSession. Have you ever tried to stored objects in this sesison? If yes, how did you do that?
Thanks,
SGM