掲示板

How to get HttpServletRequest from Icefaces portlets

thumbnail
12年前 に Nitesh Sahay によって更新されました。

How to get HttpServletRequest from Icefaces portlets

Junior Member 投稿: 58 参加年月日: 11/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?
thumbnail
12年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Try this:

ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
thumbnail
12年前 に Nitesh Sahay によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Junior Member 投稿: 58 参加年月日: 11/11/28 最新の投稿
Thanks Neil for the sols............
11年前 に Joshua Trudell によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 13 参加年月日: 12/04/03 最新の投稿
Neil Griffin:
Try this:

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



I tried this, and I got the following error:

17:38:37,227 ERROR [STDERR] java.lang.RuntimeException: Unable to get the portlet request from com.icesoft.faces.webapp.http.portlet.PortletExternalContext$4
17:38:37,228 ERROR [STDERR] 	at com.liferay.portlet.PortletRequestImpl.getPortletRequestImpl(PortletRequestImpl.java:104)
17:38:37,228 ERROR [STDERR] 	at com.liferay.portal.util.PortalImpl.getHttpServletRequest(PortalImpl.java:1760)
17:38:37,228 ERROR [STDERR] 	at com.liferay.portal.util.PortalUtil.getHttpServletRequest(PortalUtil.java:467)
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
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.
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
Neil Griffin:
Try this:

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



Hi Neil,

Good to talk to you after long time.
This is another liferay member id of mine.

Currently, I work on Login Customization Hook.
I take one of your samples as the base from, https://github.com/liferay/liferay-faces.git. (The login registration portlets)

In the LoginBackingBean.java, below code is used,
LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
ActionRequest actionRequest = (ActionRequest) liferayFacesContext.getPortletRequest();
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(actionRequest);

I get the below classcst exception in the bolded line.

java.lang.ClassCastException: com.liferay.portlet.ResourceRequestImpl cannot be cast to javax.portlet.ActionRequest:
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]

I tried the way you quoted in this blog, as well. But still get the same error.

You guidance would be very much helpful.

Thanks,
Nagaraj.
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Nagaraj,

My best guess is that you are trying to submit the form with Ajax, which would explain the ClassCastException from ResourceRequest ActionRequest.

The LoginBackingBean requires a full page postback. If you are using p:commandButton, then try setting the ajax="false" attribute.

Kind Regards,

Neil
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Thanks for letting me know. I'm glad it is working for you now. emoticon
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
Hi Neil,

I understand. This is question is not relevant to this thread.

+ All,
My Apology guys.

Neil,

Need your help in Liferay SSL Configuration.
I'am all done with the steps following this blog.

https://www.liferay.com/web/meera.success/blog/-/blogs/liferay-portal-ssl-configuration

The liferay login page is loading successfully on https: (https://localhost:8443)
The problem start when I try to login.
when logging in with default test user. I get the "WebPage is Not Available" error.

At this time, my url in the browser is,

https://localhost/web/guest/home?p_p_id=58&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_58_struts_action=%2Flogin%2Flogin

I use the liferay jboss bundle - version: liferay-portal-6.2-ce-ga2

I tried extending https related portal properties,

company.security.auth.requires.https=true
session.enable.phishing.protection=false
web.server.protocol=https

But the issue remains same.

Your guidance would be very much helpful.


Thanks,
Nagaraj.
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
See this post.
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
Neil Griffin:
See this post.



HI Neil,

Sorry that post was mine. I wanted to post this thread as new.
At the same time, was a little specific toget it to your notice.
Hence why posted in two places.

Ofcourse no reply to that post as well till now. Waiting on it.

Luckily you saw it. Can you guide me through this problem?


Thanks,
Nagaraj.
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
Hi Neil,

Finally, I was able to crack the issue. Lesson learnt is in the post

https://www.liferay.com/community/forums/-/message_boards/message/40717480

Again, Thanks for your quick reponses always.

Thanks,
Nagaraj.
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
babu babu:
Neil Griffin:
See this post.




Hi Neil,

Not sure how to reach you. Is why messagin in this post.
Guys, please bare with me,

Neil,

This is me Nagaraj again.
Currently we are testing our portal application in the Liferay cluster environment.
And we are failing to achieve Session Replication.

It would be really great, can you take a look at the below post and help with your experience.

https://www.liferay.com/community/forums/-/message_boards/message/43112118

The person "Rahul Bhardwaj" who started the above post, is my team mate. We both work this issue currently.


Thanks,
Nagaraj.
9年前 に babu babu によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

New Member 投稿: 18 参加年月日: 11/06/17 最新の投稿
Neil Griffin:
See this post.



Hi Neil,

Not sure how to reach you. Is why messagin in this post.
Guys, please bare with me,

Neil,

This is me Nagaraj again.
Currently we are testing our portal application in the Liferay cluster environment.
And we are failing to achieve Session Replication.

It would be really great, can you take a look at the below post and help with your experience.

https://www.liferay.com/community/forums/-/message_boards/message/43112118

The person "Rahul Bhardwaj" who started the above post, is my team mate. We both work this issue currently.


Thanks,
Nagaraj.
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: How to get HttpServletRequest from Icefaces portlets

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Nagaraj,

Juan (a Liferay employee and a member of the Liferay Faces team) is helping on the clustering issue.

Kind Regards,

Neil
thumbnail
12年前 に Neil Griffin によって更新されました。

moved thread to Liferay Faces forum

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
moved thread to Liferay Faces forum
thumbnail
12年前 に Neil Griffin によって更新されました。

moved thread to Liferay Faces forum

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
moved thread to Liferay Faces forum