Fórum

sendRedirect() with RenderResponse object

thumbnail
Eric M, modificado 16 Anos atrás.

sendRedirect() with RenderResponse object

New Member Postagens: 12 Data de Entrada: 25/09/07 Postagens Recentes
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
thumbnail
Ray Augé, modificado 16 Anos atrás.

Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse obje

Liferay Legend Postagens: 1197 Data de Entrada: 08/02/05 Postagens Recentes
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).
thumbnail
Eric M, modificado 16 Anos atrás.

RE: Re: [Liferay Forums][3. Development]sendRedirect() with Rende

New Member Postagens: 12 Data de Entrada: 25/09/07 Postagens Recentes
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 Gerlock, modificado 14 Anos atrás.

RE: Re: [Liferay Forums][3. Development]sendRedirect() with Rende

New Member Postagens: 20 Data de Entrada: 28/08/09 Postagens Recentes
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.
thumbnail
Luis Rodríguez Fernández, modificado 13 Anos atrás.

RE: Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse

Junior Member Postagens: 86 Data de Entrada: 26/06/09 Postagens Recentes
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...

    <action name="Action1" class="com.action.Action1">
    			<result name="input">/WEB-INF/view/action1.jsp</result>
    			<result type="redirectAction">
    				<param name="actionName">Action2
    				<param name="portletMode">view
    				<param name="namespace">/view
    			</result>
    		</action>
    
    
    <action name="Action2" class="com.action.Action2">
    			<result name="input">/WEB-INF/view/action2.jsp</result>
    		</action>




Thanks in advance,

Luis
yoann courbin, modificado 11 Anos atrás.

RE: Re: [Liferay Forums][3. Development]sendRedirect() with RenderResponse

New Member Mensagem: 1 Data de Entrada: 25/06/12 Postagens Recentes
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