Fórum

Portlet session sharing

thumbnail
Manish Kumar Jaiswal, modificado 7 Anos atrás.

Portlet session sharing

Regular Member Postagens: 153 Data de Entrada: 25/11/08 Postagens Recentes
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 7 Anos atrás.

RE: Portlet session sharing

New Member Mensagem: 1 Data de Entrada: 27/04/17 Postagens Recentes
Hi Manish
I am facing same problem, if u got the solution please share with me.


Thanks in advance varun
Asier Larrañaga, modificado 6 Anos atrás.

RE: Portlet session sharing

New Member Postagens: 2 Data de Entrada: 03/01/17 Postagens Recentes
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 6 Anos atrás.

RE: Portlet session sharing

Junior Member Postagens: 35 Data de Entrada: 22/03/17 Postagens Recentes
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 6 Anos atrás.

RE: Portlet session sharing

New Member Postagens: 2 Data de Entrada: 03/01/17 Postagens Recentes
Yes, PortalSessionThreadLocal worked for me.

Thank you so much.