Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
larry ozo ee
IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( PortletReq
May 13, 2009 8:02 AM
Answer

larry ozo ee

Rank: New Member

Posts: 6

Join Date: April 8, 2009

Recent Posts

Trying to execute following code:

FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
PortletRequest request = (PortletRequest) ec.getRequest();

HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);

and then get an error:

Unable to get the HTTP servlet request from com.icesoft.faces.webapp.http.portlet.PortletExternalContext$4



here is my test method:

public static void testRequest() {
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
System.out.println("ContextUtil.testRequest: ec = " + ec);
Object reqObj = ec.getRequest();
System.out.println("ContextUtil.testRequest: req = " + reqObj);

System.out.println("ContextUtil.testRequest: PortletEnvironmentRenderRequest = " + (reqObj instanceof PortletEnvironmentRenderRequest));
System.out.println("ContextUtil.testRequest: RenderRequest = " + (reqObj instanceof RenderRequest));
System.out.println("ContextUtil.testRequest: PortletRequest = " + (reqObj instanceof PortletRequest));
System.out.println("ContextUtil.testRequest: ActionRequest = " + (reqObj instanceof ActionRequest));
System.out.println("ContextUtil.testRequest: HttpServletRequest = " + (reqObj instanceof HttpServletRequest));

}

method output:

ContextUtil.testRequest: ec = com.icesoft.faces.webapp.http.portlet.PortletExternalContext@132c69
ContextUtil.testRequest: req = com.icesoft.faces.webapp.http.portlet.PortletExternalContext$4@c8a8b7
ContextUtil.testRequest: PortletEnvironmentRenderRequest = true
ContextUtil.testRequest: RenderRequest = true
ContextUtil.testRequest: PortletRequest = true
ContextUtil.testRequest: ActionRequest = false
ContextUtil.testRequest: HttpServletRequest = false
Alfred Chan
RE: IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( Portlet
June 1, 2009 9:21 PM
Answer

Alfred Chan

Rank: New Member

Posts: 5

Join Date: June 6, 2008

Recent Posts

I have same problem!! Any one help?
Alex Wallace
RE: IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( Portlet
June 2, 2009 7:08 AM
Answer

Alex Wallace

Rank: Liferay Master

Posts: 640

Join Date: November 4, 2007

Recent Posts

My post may be worthless, because I'm not trying what you are doing, I will only suggest to check if you can run this code in your bean, inside the constructor.

Some objects otherwise available to other frameworks at any time, when using IceFaces, are only available at bean instantiation.

This may not be your issue but I felt compelled to suggest you try it.

Thanks!
John Rose
RE: IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( Portlet
July 17, 2009 5:17 AM
Answer

John Rose

Rank: New Member

Posts: 1

Join Date: July 17, 2009

Recent Posts

I'm having the very same exception and putting:

FacesContext fc = FacesContext.getCurrentInstance();
PortletRequest portletRequest = (PortletRequest) fc.getExternalContext().getRequest();
HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(portletRequest);

in the constructor of the managed bean does not work any better.

Thanks,
John
Jan Zarnikov
RE: IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( Portlet
August 18, 2010 3:01 AM
Answer

Jan Zarnikov

Rank: New Member

Posts: 1

Join Date: August 18, 2010

Recent Posts

I've found a solution! emoticon


1PortletRequest portletRequest = (PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
2PortletRequest realPortletRequest = (PortletRequest) portletRequest.getAttribute("javax.portlet.request");
3HttpServletRequest request = PortalUtil.getHttpServletRequest(realPortletRequest);


The first PortletRequest (the one which you get from ExternalContext) is created by IceFaces and cannot be used to retrieve the original HttpServletRequest. With getAttribute("javax.portlet.request") you get the original PortletRequest created by the portlet container (the Liferay implementation of PortletRequest). With that one you can get the HttpServletRequest.

Tested on IceFaces 1.8.2 and Lifaray 5.2.3.

Hope this helped.
Nicola Cogotti
RE: IceFaces 1.8 + Liferay 5.2.2 PortalUtil.getHttpServletRequest( Portlet
April 27, 2011 3:55 PM
Answer

Nicola Cogotti

Rank: New Member

Posts: 1

Join Date: April 27, 2011

Recent Posts

Hello there,

I am very new of Liferay and I am using it with Icefaces 1.8 and Jboss.

I am getting a lot of problem trying to get the CompanyId to create a new user I have tryed this code :

1
2HttpServletRequest request=(HttpServletRequest)(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("com.liferay.portal.kernel.servlet.PortletServletRequest"));
3PortalUtil.getCompany(request).getCompanyId();


But I get a null point Exception when i try to execute it.

I have also tryed the solution you have found in this post but I cannot find the class PortletRequest ....

How can I include this class in my project?

Thanks to everybody

Nick