-
1. Re: Session parameters + more same portlets in one portal page
kenfinni May 6, 2013 8:54 AM (in response to mbasovni)Martin,
Just to clarify, if you're using JSF managed beans then @ManagedBean should be present on the bean whether you use @ViewScoped or @SessionScoped.
Another thing to check is to make sure that the @SessionScoped annotation being used is the JSF one and not the CDI one.
Can you elaborate on what you mean by "change the user of one portlet"? Does that mean log out and log in with a different user account?
-
2. Re: Session parameters + more same portlets in one portal page
mbasovni May 7, 2013 1:34 PM (in response to kenfinni)I was using:
import javax.enterprise.context.SessionScoped + import javax.inject.Named
and session bean attributes were overwriting... Portlets were saving to APPLICATION SESSION apparently...
Now I tried:
javax.faces.bean.SessionScoped + javax.faces.bean.ManagedBean
and it seams it works!
Just for assurance:
Now portlet bridge will save session beans attributes to PORTLET SESSION? It is my target!!! My portal will contain several same portlets and they must have different session scopes!
It is ok if i am using anotation injection @javax.inject.Inject. Or would be better to use @javax.ejb.EJB?
-
3. Re: Session parameters + more same portlets in one portal page
kenfinni May 7, 2013 1:40 PM (in response to mbasovni)The SessionScoped you were using is the CDI one, which without CDI being enabled would have no meaning to JSF.
If a JSF Managed Bean is annotated with @SessionScoped and @ManagedBean, then that will be session scoped to JSF, they will not be available as attributes on the Portlet Session.
So each portlet in the portal needs to have different session scope data for the same user? Or do you mean that the same portlet will contain different session data for different user sessions? The former is not possible, but the latter is.
javax.inject.Inject would only apply if you're using CDI. To perform injection with JSF, take a look at: http://www.mkyong.com/jsf2/injecting-managed-beans-in-jsf-2-0/
-
4. Re: Session parameters + more same portlets in one portal page
mbasovni May 7, 2013 2:50 PM (in response to kenfinni)Yes I need to have portlets which session will be both unique for each user and each portlet instance (of same portlet) will have different session scope (PORTLET SESSION SCOPE). Is it possible? No i am mapping session variables to portlet session manually:
Object objSession = FacesContext.getCurrentInstance().getExternalContext().getSession(false); if (objSession instanceof PortletSession) { PortletSession portalSession = (PortletSession) objSession; portalSession.setAttribute(attrName, object, PortletSession.PORTLET_SCOPE); }
-
5. Re: Session parameters + more same portlets in one portal page
kenfinni May 7, 2013 2:55 PM (in response to mbasovni)If you're setting attributes into the PORTLET_SCOPE of the PortletSession, as above, then those attributes will be unique to a user and a portlet instance (so the same portlet used multiple times on a portal page will see different values).
So it sounds like it should do what you want
-
6. Re: Session parameters + more same portlets in one portal page
mbasovni May 7, 2013 5:50 PM (in response to kenfinni)Yes! This is what I want. I works for me now. I only want to know if there is a "better practise" for this problem => "more instances of one portlet on one portal page for one user session"
Thank you very much!
-
7. Re: Session parameters + more same portlets in one portal page
kenfinni May 8, 2013 1:29 PM (in response to mbasovni)To my knowledge there isn't another way to deal with that situation