Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Eric Massague
sendRedirect() with RenderResponse object
February 19, 2008 4:50 AM
Answer

Eric Massague

Rank: New Member

Posts: 12

Join Date: September 25, 2007

Recent Posts

Hi all,

i am trying to call the sendRedirect(url) method within the render method in an action class. My problem is that i have the RenderResponse object which doesn't provide the sendRedirect(urrl) method.

Does anyone know how to convert the renderresponse object to a httpservletresponse object ?? Or, at least, a way to simulate the sendRedirect(url) method with the renderresponse object ?

Thanks a lot !

Èric
Ray Augé
Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse obje
February 19, 2008 6:24 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1195

Join Date: February 7, 2005

Recent Posts

You're trying to do something which is illegal from the stand point of
the portlet spec... even if you were to get the underlying
Implementation object and get the HttpServletResonse from that, you'd
still get an error as this is expressly disallowed during the render
phase.

The way to do it is either in the Action phase, or from your returned
html (via js).
Eric Massague
RE: Re: [Liferay Forums][3. Development]sendRedirect() with Rende
February 19, 2008 7:14 AM
Answer

Eric Massague

Rank: New Member

Posts: 12

Join Date: September 25, 2007

Recent Posts

I could solve the problem using the PortalUtil class which is provided by Liferay using the getHttpServletResponse() method. Whether it is illegal or not, Liferay can do it .

Thanks anyway.

Eric
Shawn G
RE: Re: [Liferay Forums][3. Development]sendRedirect() with Rende
September 29, 2009 3:05 PM
Answer

Shawn G

Rank: New Member

Posts: 20

Join Date: August 28, 2009

Recent Posts

I know this is an old thread, but I'm stuck on something similar and was hoping someone had an easy answer.

I have a portlet that's entire purpose is to read a cookie, and if the cookie is set to a certain value do a server-side redirect to another URL. It seems like I need to call the actionResponse.sendRedirect method within processAction, but I don't know how to invoke processAction from my doView method.

I'm new to Java so the whole concept of render and action modes is still quite new to me. Any help is appreciated.
Luis Rodríguez Fernández
RE: Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse
March 10, 2011 11:01 AM
Answer

Luis Rodríguez Fernández

Rank: Junior Member

Posts: 86

Join Date: June 26, 2009

Recent Posts

Hi Ray,

I am developing a portlet using struts2 over Liferay Portal (5.2.3 distribution over Apache Tomcat 6) I also want to redirect to Action2 from Action1.

I can do the redirect, but my problem is that when Action2 is processed the Action1 url remains, so if you push the f5 key the Action1 is executed. It seems that the sendRedirect() method doesn't work...

 1    <action name="Action1" class="com.action.Action1">
 2                <result name="input">/WEB-INF/view/action1.jsp</result>
 3                <result type="redirectAction">
 4                    <param name="actionName">Action2</param>
 5                    <param name="portletMode">view</param>
 6                    <param name="namespace">/view</param>
 7                </result>
 8            </action>
 9   
10   
11    <action name="Action2"
12                class="com.action.Action2">
13                <result name="input">/WEB-INF/view/action2.jsp</result>
14            </action>




Thanks in advance,

Luis
yoann courbin
RE: Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse
June 25, 2012 12:56 AM
Answer

yoann courbin

Rank: New Member

Posts: 1

Join Date: June 25, 2012

Recent Posts

Hi,

i'm interesting to this point of Liferay, I understand what Ray said.

My problem is :
In a specific case of navigation, I would like to redirect the user to the home page. The test, which determines if I must redirect or not, is in a doView Method.

I would like to try an other way that you mentionned ( javascript redirect ), because the user can see a part of the page before the redirection. I would like that the redirection happens during the same process.

I tried to use the method sendRedirect in a HttpServletResponse object (via PortalUtil.getHttpServletResponse(renderResponse) ), the method throw neither exceptions nor errors but there is no redirection.

Do you know a different way of javascript redirection? If no, I think I will have no more choice ^^

Thanks a lot.

Yoann