Kombinált nézet Egyszerű nézet Fa-nézet
Szálak [ Előző | Következő ]
toggle
Nitesh Sahay
How to get HttpServletRequest from Icefaces portlets
2012. április 6. 4:32
Válasz

Nitesh Sahay

Rangsorolás: Junior Member

Hozzászólások: 50

Csatlakozás dátuma: 2011. november 28.

Legújabb hozzászólások

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
2012. április 10. 14:59
Válasz

Neil Griffin

LIFERAY STAFF

Rangsorolás: Liferay Legend

Hozzászólások: 1455

Csatlakozás dátuma: 2005. július 26.

Legújabb hozzászólások

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
2012. április 13. 6:21
Válasz

Nitesh Sahay

Rangsorolás: Junior Member

Hozzászólások: 50

Csatlakozás dátuma: 2011. november 28.

Legújabb hozzászólások

Thanks Neil for the sols............
Joshua Trudell
RE: How to get HttpServletRequest from Icefaces portlets
2013. április 3. 10:39
Válasz

Joshua Trudell

Rangsorolás: New Member

Hozzászólások: 1

Csatlakozás dátuma: 2012. április 3.

Legújabb hozzászólások

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
2013. április 3. 11:40
Válasz

Neil Griffin

LIFERAY STAFF

Rangsorolás: Liferay Legend

Hozzászólások: 1455

Csatlakozás dátuma: 2005. július 26.

Legújabb hozzászólások

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.