Foren
liferay sessions
Daniel Wilmes, geändert vor 12 Jahren.
liferay sessions
Regular Member Beiträge: 164 Beitrittsdatum: 23.05.11 Neueste Beiträge
I am using liferay 6.0.6
with tomcat-6.0.29
I am not at all familiar with session variables, but I need to create a session variable that is shared between all customer portlets, a theme, and the portal.
I noticed there was a LiferayPortletSession, but I think the scope is related only to the portlet?? Any ideas would be great.
Thanks Daniel
with tomcat-6.0.29
I am not at all familiar with session variables, but I need to create a session variable that is shared between all customer portlets, a theme, and the portal.
I noticed there was a LiferayPortletSession, but I think the scope is related only to the portlet?? Any ideas would be great.
Thanks Daniel
Raja Nagendra Kumar, geändert vor 12 Jahren.
RE: liferay sessions
Expert Beiträge: 484 Beitrittsdatum: 02.03.06 Neueste Beiträge
You could see
http://blogs.oracle.com/deepakg/entry/jsr286_public_render_parameter_feature
public render parameters.
Regards,
Nagendra
http://blogs.oracle.com/deepakg/entry/jsr286_public_render_parameter_feature
public render parameters.
Regards,
Nagendra
Luca kk, geändert vor 12 Jahren.
RE: liferay sessions
Expert Beiträge: 284 Beitrittsdatum: 07.12.10 Neueste Beiträge
Hi Daniel,
take a look here:
http://www.liferay.com/community/forums/-/message_boards/message/10132256
take a look here:
http://www.liferay.com/community/forums/-/message_boards/message/10132256
Philippe CHEIPE, geändert vor 12 Jahren.
RE: liferay sessions
Junior Member Beiträge: 61 Beitrittsdatum: 12.08.10 Neueste Beiträge
I would do a :
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(portletRequest));
Then access the session from the httpReq : it will be the global one.
Hope it helps
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(portletRequest));
Then access the session from the httpReq : it will be the global one.
Hope it helps
Daniel Wilmes, geändert vor 12 Jahren.
RE: liferay sessions
Regular Member Beiträge: 164 Beitrittsdatum: 23.05.11 Neueste Beiträge
Thank you for all the replies. I will look at them. Thanks again for the quick response.
Sagar A Vyas, geändert vor 12 Jahren.
RE: liferay sessions
Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste Beiträge
Hi All,
We can simply use as below to get/set session attribute.
PortletSession portletSession = portletRequest.getPortletSession();
portletSession.setAttribute(name, value,scope);
Name = Name of session attribute - by using this name you can get withing defined scope
Value = Value of session attribute
Scope = scope could be APPLICATION_SCOPE or PORTLET_SCOPE
You have to set inside your liferay-portlet,xml
<private-session-attributes>false</private-session-attributes>
Thanks,
Sagar Vyas
We can simply use as below to get/set session attribute.
PortletSession portletSession = portletRequest.getPortletSession();
portletSession.setAttribute(name, value,scope);
Name = Name of session attribute - by using this name you can get withing defined scope
Value = Value of session attribute
Scope = scope could be APPLICATION_SCOPE or PORTLET_SCOPE
You have to set inside your liferay-portlet,xml
<private-session-attributes>false</private-session-attributes>
Thanks,
Sagar Vyas
Daniel Wilmes, geändert vor 12 Jahren.
RE: liferay sessions
Regular Member Beiträge: 164 Beitrittsdatum: 23.05.11 Neueste Beiträge
Thank you for the reply this is what I have done, but I am not storing the object in the session properly and was wondering what I am doing incorrectly.
Customer customer = CustomerServiceUtil.getPrimaryCustomer(cUser);
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest));
httpReq.setAttribute("current-customer", customer);
Customer c = null;
if(httpReq.getSession().getAttribute("current-customer") != null){
c = (Customer) httpReq.getSession().getAttribute("current-customer");
System.out.println(c.getCompanyName());
}
Phoenix Zerin, geändert vor 12 Jahren.
RE: liferay sessions
Junior Member Beiträge: 60 Beitrittsdatum: 28.06.11 Neueste Beiträge
On this line:
Should you be doing this, instead?
httpReq.setAttribute("current-customer", customer);
Should you be doing this, instead?
httpReq.getSession().setAttribute("current-customer", customer);
Daniel Wilmes, geändert vor 12 Jahren.
RE: liferay sessions
Regular Member Beiträge: 164 Beitrittsdatum: 23.05.11 Neueste Beiträge
We decided not to use sessions, but use service builder and put our service jar on the tomcat global class path so all portlets can get and set fields in the database. Thanks though.