Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
PrincipalThreadLocal.getUserId() is 0 for Icefaces (1.8.2) portlets
Hi,
I am basically implementing logger on the generic actions like saving portlet's preferences in store method of
Why is this strange behavior?
Please share your valuable feedback.
Cross Posted: http://stackoverflow.com/questions/43116457/principalthreadlocal-getuserid-is-0-for-icefaces-1-8-2-portlets
I am basically implementing logger on the generic actions like saving portlet's preferences in store method of
PortletPreferencesImpl. Here I am calling PrincipalThreadLocal.getUserId() to get user information. Everything is fine for the Liferay OTB's portlets and for Primefaces 5.2 portlets but when I am saving preferences of Icefaces (1.8.2) portlet, I am always getting 0 from PrincipalThreadLocal.getUserId().Why is this strange behavior?
Please share your valuable feedback.
Cross Posted: http://stackoverflow.com/questions/43116457/principalthreadlocal-getuserid-is-0-for-icefaces-1-8-2-portlets
Hi Parkash,
What version of Liferay Portal are you using?
ICEfaces 1.8 is an outdated version of ICEfaces that requires JSF 1.2 (circa 2008) and is only supported up through Liferay Portal 6.2.
I think the problem you are encountering is caused by the fact that ICEfaces 1.8 only participates in the portlet lifecycle during the initial HTTP GET of the portal page. After that, all XHR requests go through the ICEfaces servlet, rather that a portlet lifecycle ResourceRequest. That would explain why Liferay's PrincipalThreadLocal is not working.
Are you able to upgrade to a more modern version of ICEfaces such as 4.1 or 4.2? Similar to PrimeFaces 5/6, those versions of ICEfaces utilize the portlet lifecycle via Liferay Faces Bridge.
Kind Regards,
Neil
What version of Liferay Portal are you using?
ICEfaces 1.8 is an outdated version of ICEfaces that requires JSF 1.2 (circa 2008) and is only supported up through Liferay Portal 6.2.
I think the problem you are encountering is caused by the fact that ICEfaces 1.8 only participates in the portlet lifecycle during the initial HTTP GET of the portal page. After that, all XHR requests go through the ICEfaces servlet, rather that a portlet lifecycle ResourceRequest. That would explain why Liferay's PrincipalThreadLocal is not working.
Are you able to upgrade to a more modern version of ICEfaces such as 4.1 or 4.2? Similar to PrimeFaces 5/6, those versions of ICEfaces utilize the portlet lifecycle via Liferay Faces Bridge.
Kind Regards,
Neil
Thank you very much Neil for your response.
Yes, we have been using Liferay 6.2 and sorry we can't upgrade icefaces as we are totally moving to primefaces for newer development. Though, we have to provide support for our older version.
Well, I would like to share my investigation:
PrincipalThreadLocal.getUserId() is 0 in store() method of PortletPreferencesImpl when saving preferences any icefaces based portlet.
Reason:
For each request, com.liferay.portal.servlet.MainServlet.service:457 > setPrincipal:1305 of Liferay is responsible to set userId in PrincipalThreadLocal. However, for icefaces portlets Liferay's MainServlet does not get invoked, as there is exactly same named servlet (com.icesoft.faces.webapp.http.servlet.MainServlet) in icefaces jar, which gets invoked instead.
Traces:
Liferay OTB's / Primefaces portlets:
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Icefaces portlets:
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:204)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Yes, we have been using Liferay 6.2 and sorry we can't upgrade icefaces as we are totally moving to primefaces for newer development. Though, we have to provide support for our older version.
Well, I would like to share my investigation:
PrincipalThreadLocal.getUserId() is 0 in store() method of PortletPreferencesImpl when saving preferences any icefaces based portlet.
Reason:
For each request, com.liferay.portal.servlet.MainServlet.service:457 > setPrincipal:1305 of Liferay is responsible to set userId in PrincipalThreadLocal. However, for icefaces portlets Liferay's MainServlet does not get invoked, as there is exactly same named servlet (com.icesoft.faces.webapp.http.servlet.MainServlet) in icefaces jar, which gets invoked instead.
Traces:
Liferay OTB's / Primefaces portlets:
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:523)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Icefaces portlets:
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:204)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Hi Parkash,
We have an ICEfaces 1.8 version of our jsf-applicant-portlet demo available. I recommend you study the source code in order to learn how to read/store portlet preferences.
One thing I'd like to mention is that the pom.xml descriptor contains an extra dependency that helps add JSR 329 style EL keywords (such as mutablePortletPreferencesValues), even though ICEfaces 1.8 does not utilize the JSR 329 bridge standard:
Kind Regards,
Neil
We have an ICEfaces 1.8 version of our jsf-applicant-portlet demo available. I recommend you study the source code in order to learn how to read/store portlet preferences.
One thing I'd like to mention is that the pom.xml descriptor contains an extra dependency that helps add JSR 329 style EL keywords (such as mutablePortletPreferencesValues), even though ICEfaces 1.8 does not utilize the JSR 329 bridge standard:
<dependency>
<groupid>com.liferay.faces</groupid>
<artifactid>com.liferay.faces.bridge.ice</artifactid>
<version>2.0.0</version>
</dependency>Kind Regards,
Neil