views:

159

answers:

4

It is posible for a portlet to read a request parameter of its surrounding page?

E.g. the URL of the page the portlet resides in is http://example.com/mypage?foo=bar Is it possible to read the "foo" parameter from a portlet that is on that page?

Portlet Container is Liferay 5.2.5.

+2  A: 

PortletRequest class has method getAttribute()

You can treat it like HttpServletRequest.

Jaromir Hamala
A: 

I've never used Liferay, but you might be able to do this using the Portlet 2.0 (JSR 286) public render parameters.

McDowell
+1  A: 

I haven't yet found a way besides using platform specific class com.liferay.portal.util.PortalUtil.

dragisak
+1  A: 

Yes this can be achieved with something like this -

HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(request);
HttpServletRequest originalReq = PortalUtil.getOriginalServletRequest(convertReq);
String productId = originalReq.getParameter("foo");

Where request is RenderRequest.

Tina Agrawal