Fórum

Portlet session and Thread Safety

Francesco Scali, modificado 11 Anos atrás.

Portlet session and Thread Safety

New Member Postagens: 14 Data de Entrada: 02/11/09 Postagens Recentes
Hi,
In Liferay 5.2.3 I'm using LIFERAY_SHARED_ prefix to share session attributes between the portal and the portlets.
Sometimes, but not always,from my IceFaces portlet I cannot retrieve the attribute previously set in session during my custom action (configured in servlet.service.events.pre) Do I have to access the session in synchronized mode? How is it possible (since in Icefaces session I cannot access the httpsession)?
The code I use to retrieve the attribute from the IceFaces portlet is:

FacesContext facesContext = FacesContext.getCurrentInstance();
PortletSession portletSession =
(PortletSession)facesContext.getExternalContext().getSession(false);
Object theSessionObj = portletSession.getAttribute(key, scope);

Thanks

Francesco
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Portlet session and Thread Safety

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
If you're using ICEfaces2 or ICEfaces3, then you can get the underlying HttpSession like this:
import com.liferay.portal.util.PortalUtil;
...
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
HttpSession httpSession = PortalUtil.getHttpServletRequest(portletRequest).getSession();
Francesco Scali, modificado 11 Anos atrás.

RE: Portlet session and Thread Safety

New Member Postagens: 14 Data de Entrada: 02/11/09 Postagens Recentes
unfortunately we've got IceFaces 1.8.2 emoticon
Any way to do this ?
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Portlet session and Thread Safety

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
For ICEfaces 1.x I would recommend that you consider adding PortletFaces-Tools as a dependency to your portlet. It has some nice convenience features that provide improved ICEfaces 1.x integration with Liferay.

The problem is that ICEfaces 1.x only has access to Liferay-related objects during the initial RENDER_PHASE of the portlet lifecycle. After the initial render, ICEfaces 1.x does all the ajax calls with a servlet which does not have access to the original PortletRequest.

In particular, the Liferay.java class in PortletFaces-Tools shows how to cache important objects from PortletRequest during the initial render.

ICEfaces 2.x and 3.x does not have this problem, because Liferay Faces Bridge will use the RESOURCE_PHASE of the portlet lifecycle for Ajax, which always has access to Liferay-related objects.
thumbnail
Neil Griffin, modificado 11 Anos atrás.

moved thread to Liferay Faces forum

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
moved thread to Liferay Faces forum