Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nitesh Sahay
How to get HttpServletRequest from Icefaces portlets
April 6, 2012 4:32 AM
Answer

Nitesh Sahay

Rank: Junior Member

Posts: 50

Join Date: November 28, 2011

Recent Posts

Hi,
I am working with liferay 6.0+ ,I am Using the following code

ExternalContext extcontext = FacesContext.getCurrentInstance().getExternalContext();
RenderRequest req = (RenderRequest) extcontext.getRequest();
HttpServletRequest request = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(req));





to get the HttpServletRequest,but it throws an class cast exception...exception is as follows
java.lang.ClassCastException: com.liferay.portlet.ResourceRequestImpl cannot be cast to javax.portlet.RenderRequest


can any one guid me . What to do?
Neil Griffin
RE: How to get HttpServletRequest from Icefaces portlets
April 10, 2012 2:59 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1422

Join Date: July 26, 2005

Recent Posts

Try this:

1ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
2PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
3HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
Nitesh Sahay
RE: How to get HttpServletRequest from Icefaces portlets
April 13, 2012 6:21 AM
Answer

Nitesh Sahay

Rank: Junior Member

Posts: 50

Join Date: November 28, 2011

Recent Posts

Thanks Neil for the sols............
Joshua Trudell
RE: How to get HttpServletRequest from Icefaces portlets
April 3, 2013 10:39 AM
Answer

Joshua Trudell

Rank: New Member

Posts: 1

Join Date: April 3, 2012

Recent Posts

Neil Griffin:
Try this:

1ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
2PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
3HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);



I tried this, and I got the following error:

117:38:37,227 ERROR [STDERR] java.lang.RuntimeException: Unable to get the portlet request from com.icesoft.faces.webapp.http.portlet.PortletExternalContext$4
217:38:37,228 ERROR [STDERR]     at com.liferay.portlet.PortletRequestImpl.getPortletRequestImpl(PortletRequestImpl.java:104)
317:38:37,228 ERROR [STDERR]     at com.liferay.portal.util.PortalImpl.getHttpServletRequest(PortalImpl.java:1760)
417:38:37,228 ERROR [STDERR]     at com.liferay.portal.util.PortalUtil.getHttpServletRequest(PortalUtil.java:467)
Neil Griffin
RE: How to get HttpServletRequest from Icefaces portlets
April 3, 2013 11:40 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1422

Join Date: July 26, 2005

Recent Posts

From looking at the java.lang.RuntimeException, my best guess is that you are using ICEfaces 1.8 and not ICEfaces 2/3.

The problem is that ICEfaces 1.8 does not utilize the Portlet 2.0 RESOURCE_PHASE (ResourceRequest) for Ajax. Instead, ajax requests are made from the browser directly to the ICEfaces servlet. So the basic problem is that there isn't an underlying PortletRequest object with ICEfaces 1.8 Ajax.

Are you able to upgrade to ICEfaces 3.2 and Liferay Faces Bridge? If not, then what do you need to get from the underlying HttpServletRequest? Depending on what you need, there *might* be a way to get what you are looking for.