フォーラム

ホーム » Liferay Faces » Liferay Faces - English

構造的に表示 平面上に表示 ツリー上に表示
スレッド数 [ 前へ | 次へ ]
toggle
Nitesh Sahay
How to get HttpServletRequest from Icefaces portlets
2012/04/06 4:32
答え

Nitesh Sahay

ランク: Junior Member

投稿数: 50

参加年月日: 2011/11/28

最近の投稿

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/04/10 14:59
答え

Neil Griffin

LIFERAY STAFF

ランク: Liferay Legend

投稿数: 1422

参加年月日: 2005/07/26

最近の投稿

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/04/13 6:21
答え

Nitesh Sahay

ランク: Junior Member

投稿数: 50

参加年月日: 2011/11/28

最近の投稿

Thanks Neil for the sols............
Joshua Trudell
RE: How to get HttpServletRequest from Icefaces portlets
2013/04/03 10:39
答え

Joshua Trudell

ランク: New Member

投稿数: 1

参加年月日: 2012/04/03

最近の投稿

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/04/03 11:40
答え

Neil Griffin

LIFERAY STAFF

ランク: Liferay Legend

投稿数: 1422

参加年月日: 2005/07/26

最近の投稿

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.