Foren

portletRequest.getPortletSession() returns null

Rafael Rodrigues, geändert vor 9 Jahren.

portletRequest.getPortletSession() returns null

New Member Beiträge: 3 Beitrittsdatum: 21.08.14 Neueste Beiträge
In my project, I want to use Liferay Login to autenticate the users, for that, I developed a hook that adds functionalities to the liferay login, the rest of the project is adapted from a one previously developed for IBM websphere and its located in another war file.

I guess there is no problem, but this project requires some login information saved in PortletSession, like the userName, sessionUuid...

I tried this:

	PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
	PortletSession session = portletRequest.getPortletSession();
	session.setAttribute("TEST_PORTLET_SESSION", "GOT_THERE", PortletSession.APPLICATION_SCOPE);
	session.setAttribute("webtoolPortlets."+"sessionUuid", session.getId(), PortletSession.APPLICATION_SCOPE);


but it returns null for the PortletSession.

So my question is: How do I transfer this information from the plugin to the application PortletSession?

Thanks in advance!
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: portletRequest.getPortletSession() returns null

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
First, this thread has nothing to do with your request, you should have started a new thread...

That said, application scope only works between portlets in the same war file. if you are in different wars, then you need a completely different mechanism. I'd suggest cookies for client side or database for server side.
thumbnail
Kyle Joseph Stiemann, geändert vor 9 Jahren.

Moved.

Liferay Master Beiträge: 760 Beitrittsdatum: 14.01.13 Neueste Beiträge
Moved to Home » Liferay Portal » English » 3. Development
thumbnail
Subhasis Roy, geändert vor 9 Jahren.

RE: portletRequest.getPortletSession() returns null

Expert Beiträge: 275 Beitrittsdatum: 20.01.12 Neueste Beiträge
you can try the following -

PortletSession portletSession = renderRequest.getPortletSession();  
portletSession.getAttribute("param1" ,PortletSession.APPLICATION_SCOPE);
thumbnail
Andew Jardine, geändert vor 9 Jahren.

RE: portletRequest.getPortletSession() returns null

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
I think David already explained that APPLICATION_SCOPE only works when plugins are in the SAME war file. The original post states that he has more than one war file, so APPLICATION_SCOPE won't help here.
thumbnail
Subhasis Roy, geändert vor 9 Jahren.

RE: portletRequest.getPortletSession() returns null

Expert Beiträge: 275 Beitrittsdatum: 20.01.12 Neueste Beiträge
i think, you can try for IPC mechanism