Foros de discusión

Portlet session sharing

thumbnail
Manish Kumar Jaiswal, modificado hace 7 años.

Portlet session sharing

Regular Member Mensajes: 153 Fecha de incorporación: 25/11/08 Mensajes recientes
Hi Friends ,

I was just trying to use com.liferay.portlet.private-session-attributes=false to share some value between 2 portlets (IPC) in Liferay 7 .
this should be very simple but i don't know where i am going wrong .I have created 2 portlets
1) Sender
2) Receiver

Sender has this code

@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true",
		"javax.portlet.display-name=IPC-PortletSession-Sender Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user",
		"com.liferay.portlet.private-session-attributes=false"
	},
	service = Portlet.class
)
public class IPCPortletSessionSenderPortlet extends MVCPortlet {
	
	@ProcessAction(name = "getData")
	public void getData(ActionRequest actionRequest, ActionResponse actionResponse)
			throws IOException, PortletException, SystemException {
		String userEmailAddress = ParamUtil.getString(actionRequest, "userEmailAddress");
		PortletSession portletSession = actionRequest.getPortletSession();
		System.out.println("userEmailAddress >>"+userEmailAddress);
		portletSession.setAttribute("userEmailAddress", userEmailAddress, PortletSession.APPLICATION_SCOPE);

}
}


I get the value of userEmailAddress here .
and receiver has this code

@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true",
		"javax.portlet.display-name=IPC-PortletSession-Receiver Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user",
		"com.liferay.portlet.private-session-attributes=false"
	},
	service = Portlet.class
)
public class IPCPortletSessionReceiverPortlet extends MVCPortlet {
	
	@Override
	public void render(RenderRequest renderRequest, RenderResponse renderResponse)
			throws IOException, PortletException {
		String message = null;
		ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
		PortletSession portletSessionobject = renderRequest.getPortletSession();
		String userEmailAddress = (String)portletSessionobject.getAttribute("userEmailAddress", PortletSession.APPLICATION_SCOPE);
		System.out.println("userEmailAddress >>>>>>>>>>>>>"+userEmailAddress);
		
		super.render(renderRequest, renderResponse);
	}
}


here i don't get the value of userEmailAddress . So what is wrong in the code . I think this should be simple but I don't know what is wrong here . Can some one help me out . Thanks in advance ...Manish
Varun Kumar, modificado hace 6 años.

RE: Portlet session sharing

New Member Mensaje: 1 Fecha de incorporación: 27/04/17 Mensajes recientes
Hi Manish
I am facing same problem, if u got the solution please share with me.


Thanks in advance varun
Asier Larrañaga, modificado hace 6 años.

RE: Portlet session sharing

New Member Mensajes: 2 Fecha de incorporación: 3/01/17 Mensajes recientes
According to this issue, https://issues.liferay.com/browse/LPS-66826, portlet session sharing doesn't work in Liferay 7 GA3.

It looks like it is fixed for DXP, but can this be fixed in CE?
JB Shaik, modificado hace 6 años.

RE: Portlet session sharing

Junior Member Mensajes: 35 Fecha de incorporación: 22/03/17 Mensajes recientes
Assuming that you want to pass attributes in session, please check If the solution in below link fixes your issue.

https://web.liferay.com/community/forums/-/message_boards/view_message/88949571#_19_message_88978751
Asier Larrañaga, modificado hace 6 años.

RE: Portlet session sharing

New Member Mensajes: 2 Fecha de incorporación: 3/01/17 Mensajes recientes
Yes, PortalSessionThreadLocal worked for me.

Thank you so much.