You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Crishantha Nanayakkara <c....@gmail.com> on 2009/05/31 10:20:02 UTC

response.sendRedirect() with Struts2 within a portlet

Hi,

I have a requirement to use a response.sendRedirect() within my Action
class. Basically this action class is used to manipulate a porltet. 

Unlike Struts1, we do not directly have any processAction() method and
ActionRequest and ActionResponse objects to do a response.sendRedirect. 

I just want to know how do we get about executing the response.sendRedirect
with Struts2? What should be the interface to implement within the action
class to do this. (Just like ServletRequestAware to get the
HttpServletRequest)

Appriciate your help on this. 

Best Regards
Crishantha
-- 
View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Girish Naik <gi...@gmail.com>.
There is no documentation as such, but i read it in the book 'Struts 2
Design and Programming: A Tutorial' by Budi Kurniawan.

This result is added to the action mapping in struts.xml file -
e.g.:

        *<action name="login"
            class="com.something.webapp.action.LoginAction" method="login">
            <result name="success" type="redirect">home.action</result>
            <result name="sign_in" type="tiles">
                tiles:showLoginPage
            </result>
            <result name="home" type="redirect">home.action</result>
           <result name="failure" type="redirect-action">
                <param name="namespace">/</param>
                <param name="actionName">home</param>
            </result>
        </action>*


Regards,
---------------------------------------------------------
Girish Naik
Mobile:-+91-09740091638
girish.naik@gmail.com
Helen Rowland<http://www.brainyquote.com/quotes/authors/h/helen_rowland.html>
- "One man's folly is another man's wife."

On Sun, May 31, 2009 at 9:50 PM, Martin Gainty <mg...@hotmail.com> wrote:

>
> Girish-
>
> can you provide the documentation which suggests Result and Result with
> params for redirect and redirect-action types?
>
> Thanks!
> Martin Gainty
>
> I would never join a club which would have me as a member -  Groucho Marx
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
> > Date: Sun, 31 May 2009 13:56:24 +0530
> > Subject: Re: response.sendRedirect() with Struts2 within a portlet
> > From: girish.naik@gmail.com
> > To: user@struts.apache.org
> >
> > I have used redirect in struts.xml file in two ways as :
> >
> > 1.
> >
> > <result name="home" type="redirect">home.action</result>
> >
> > 2.
> >
> > <result name="failure" type="redirect-action">
> >                 <param name="namespace">/</param>
> >                 <param name="actionName">home</param>
> >             </result>
> >
> >
> > Regards,
> > ---------------------------------------------------------
> > Girish Naik
> > Mobile:-+91-09740091638
> > girish.naik@gmail.com
> > Groucho Marx <
> http://www.brainyquote.com/quotes/authors/g/groucho_marx.html>
> > - "A hospital bed is a parked taxi with the meter running."
> >
> > On Sun, May 31, 2009 at 1:50 PM, Crishantha Nanayakkara <
> > c.nanayakkara@gmail.com> wrote:
> >
> > >
> > > Hi,
> > >
> > > I have a requirement to use a response.sendRedirect() within my Action
> > > class. Basically this action class is used to manipulate a porltet.
> > >
> > > Unlike Struts1, we do not directly have any processAction() method and
> > > ActionRequest and ActionResponse objects to do a response.sendRedirect.
> > >
> > > I just want to know how do we get about executing the
> response.sendRedirect
> > > with Struts2? What should be the interface to implement within the
> action
> > > class to do this. (Just like ServletRequestAware to get the
> > > HttpServletRequest)
> > >
> > > Appriciate your help on this.
> > >
> > > Best Regards
> > > Crishantha
> > > --
> > > View this message in context:
> > >
> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
> > > Sent from the Struts - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
>
> _________________________________________________________________
> Windows Live™: Keep your life in sync.
> http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009

RE: response.sendRedirect() with Struts2 within a portlet

Posted by Martin Gainty <mg...@hotmail.com>.
Girish-

can you provide the documentation which suggests Result and Result with params for redirect and redirect-action types?

Thanks!
Martin Gainty 

I would never join a club which would have me as a member -  Groucho Marx
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Sun, 31 May 2009 13:56:24 +0530
> Subject: Re: response.sendRedirect() with Struts2 within a portlet
> From: girish.naik@gmail.com
> To: user@struts.apache.org
> 
> I have used redirect in struts.xml file in two ways as :
> 
> 1.
> 
> <result name="home" type="redirect">home.action</result>
> 
> 2.
> 
> <result name="failure" type="redirect-action">
>                 <param name="namespace">/</param>
>                 <param name="actionName">home</param>
>             </result>
> 
> 
> Regards,
> ---------------------------------------------------------
> Girish Naik
> Mobile:-+91-09740091638
> girish.naik@gmail.com
> Groucho Marx <http://www.brainyquote.com/quotes/authors/g/groucho_marx.html>
> - "A hospital bed is a parked taxi with the meter running."
> 
> On Sun, May 31, 2009 at 1:50 PM, Crishantha Nanayakkara <
> c.nanayakkara@gmail.com> wrote:
> 
> >
> > Hi,
> >
> > I have a requirement to use a response.sendRedirect() within my Action
> > class. Basically this action class is used to manipulate a porltet.
> >
> > Unlike Struts1, we do not directly have any processAction() method and
> > ActionRequest and ActionResponse objects to do a response.sendRedirect.
> >
> > I just want to know how do we get about executing the response.sendRedirect
> > with Struts2? What should be the interface to implement within the action
> > class to do this. (Just like ServletRequestAware to get the
> > HttpServletRequest)
> >
> > Appriciate your help on this.
> >
> > Best Regards
> > Crishantha
> > --
> > View this message in context:
> > http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009

Re: response.sendRedirect() with Struts2 within a portlet

Posted by Girish Naik <gi...@gmail.com>.
I have used redirect in struts.xml file in two ways as :

1.

<result name="home" type="redirect">home.action</result>

2.

<result name="failure" type="redirect-action">
                <param name="namespace">/</param>
                <param name="actionName">home</param>
            </result>


Regards,
---------------------------------------------------------
Girish Naik
Mobile:-+91-09740091638
girish.naik@gmail.com
Groucho Marx <http://www.brainyquote.com/quotes/authors/g/groucho_marx.html>
- "A hospital bed is a parked taxi with the meter running."

On Sun, May 31, 2009 at 1:50 PM, Crishantha Nanayakkara <
c.nanayakkara@gmail.com> wrote:

>
> Hi,
>
> I have a requirement to use a response.sendRedirect() within my Action
> class. Basically this action class is used to manipulate a porltet.
>
> Unlike Struts1, we do not directly have any processAction() method and
> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>
> I just want to know how do we get about executing the response.sendRedirect
> with Struts2? What should be the interface to implement within the action
> class to do this. (Just like ServletRequestAware to get the
> HttpServletRequest)
>
> Appriciate your help on this.
>
> Best Regards
> Crishantha
> --
> View this message in context:
> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: response.sendRedirect() with Struts2 within a portlet

Posted by Dave Newton <ne...@yahoo.com>.
Crishantha Nanayakkara wrote:
> Unlike Struts1, we do not directly have any processAction() method and
> ActionRequest and ActionResponse objects to do a response.sendRedirect. 
> 
> I just want to know how do we get about executing the response.sendRedirect
> with Struts2? What should be the interface to implement within the action
> class to do this. (Just like ServletRequestAware to get the
> HttpServletRequest)

Er, ServletResponseAware, although I'm not sure if that's the cleanest 
approach to take (I know essentially nothing about portlets).

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Crishantha Nanayakkara <c....@gmail.com>.
Hi Again,

Just wanted to clarify my requirement again. 

We are building a portal based on Liferay to provide eServices. any eService
will be launched as portlets. Hence each portlet will be a window to a
single eService. 

While developing this eService sometimes we need to redirect to a common
payment gateway, which is an external domain/ URL. Thats why this
requirement came up. We need to confine this external payment gateway page
to the calling portlet window itself rather than opening a seperate browser
for that.

The portlets are built on Liferay with the help of Struts2. 

Best Regards
Crishantha


Nils-Helge Garli wrote:
> 
> Unfortunately, you can't make an ajax request to the portlet. The ajax
> tags are not supported in a portlet, due to limitations in the JSR168
> specification. Also, I'm not quite sure what you're trying to do. Are
> you attempting to load the div with Ajax with contents from a
> different url? Have you considered using an iframe?
> 
> Nils-H
> 
> On Sun, May 31, 2009 at 10:32 PM, Crishantha Nanayakkara
> <c....@gmail.com> wrote:
>>
>> Hi Nils-H,
>>
>> I got it working by using "ActionResponse aResponse =
>> PortletActionContext.getActionResponse();" within the execute() method of
>> the action event.
>>
>> Actually my main requirement is to redirect to an external URL within my
>> portlet itself. For me to confine the external URL within the portlet
>> window, I am using the Struts2 Ajax div tag within my jsp code.
>>
>> See the JSP code below,
>>
>> <sx:head debug="false" cache="false" compressed="false" />
>>
>> <s:url id="url" action="testUrl1" portletUrlType="action"/>
>>
>> <body>
>>        <s:div id="div"/>
>>        <s:submit value="Make Request" id="submit" />
>>        <sx:bind targets="div" sources="submit" events="onclick"
>> href="%{#url}" />
>> </body>
>>
>> My execute() method looks like below,
>>
>>        public String execute() throws Exception {
>>                System.out.println("*** In the EXECUTE() method ****");
>>                System.out.println("The request object is : " + request);
>>
>>                ActionRequest aRequest =
>> PortletActionContext.getActionRequest();
>>                System.out.println("The Action request object is : " +
>> aRequest);
>>
>>                ActionResponse aResponse =
>> PortletActionContext.getActionResponse();
>>                System.out.println("The Action response object is : " +
>> aResponse);
>>
>>                aResponse.sendRedirect("http://www.google.lk");
>>
>>                return SUCCESS;
>>        }
>>
>> However, when I run this, The external URL is not loaded to the portlet
>> window. It says "undefined" within div tags.
>>
>> What should I do to make this work?
>>
>> Best Regards
>> Crishantha
>>
>> Nils-Helge Garli wrote:
>>>
>>> You can use the PortletResponseAware to get the portlet response object.
>>>
>>> Nnils-H
>>>
>>> On Sun, May 31, 2009 at 10:20 AM, Crishantha Nanayakkara
>>> <c....@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a requirement to use a response.sendRedirect() within my Action
>>>> class. Basically this action class is used to manipulate a porltet.
>>>>
>>>> Unlike Struts1, we do not directly have any processAction() method and
>>>> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>>>>
>>>> I just want to know how do we get about executing the
>>>> response.sendRedirect
>>>> with Struts2? What should be the interface to implement within the
>>>> action
>>>> class to do this. (Just like ServletRequestAware to get the
>>>> HttpServletRequest)
>>>>
>>>> Appriciate your help on this.
>>>>
>>>> Best Regards
>>>> Crishantha
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23806654.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23810555.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Crishantha Nanayakkara <c....@gmail.com>.
Hi Nilis-H,

Thanks a lot for the update. 

Yes, I am trying to redirect to an external URL by just clicking a "submit"
button within a portlet. As you said for that I am attempting to load the
div with Ajax with contents from the external URL specified purely to
display it within the portlet window.

Can I attempt "IFrame" to fulfill the same purpose? 

Best Regards
Crishantha



Nils-Helge Garli wrote:
> 
> Unfortunately, you can't make an ajax request to the portlet. The ajax
> tags are not supported in a portlet, due to limitations in the JSR168
> specification. Also, I'm not quite sure what you're trying to do. Are
> you attempting to load the div with Ajax with contents from a
> different url? Have you considered using an iframe?
> 
> Nils-H
> 
> On Sun, May 31, 2009 at 10:32 PM, Crishantha Nanayakkara
> <c....@gmail.com> wrote:
>>
>> Hi Nils-H,
>>
>> I got it working by using "ActionResponse aResponse =
>> PortletActionContext.getActionResponse();" within the execute() method of
>> the action event.
>>
>> Actually my main requirement is to redirect to an external URL within my
>> portlet itself. For me to confine the external URL within the portlet
>> window, I am using the Struts2 Ajax div tag within my jsp code.
>>
>> See the JSP code below,
>>
>> <sx:head debug="false" cache="false" compressed="false" />
>>
>> <s:url id="url" action="testUrl1" portletUrlType="action"/>
>>
>> <body>
>>        <s:div id="div"/>
>>        <s:submit value="Make Request" id="submit" />
>>        <sx:bind targets="div" sources="submit" events="onclick"
>> href="%{#url}" />
>> </body>
>>
>> My execute() method looks like below,
>>
>>        public String execute() throws Exception {
>>                System.out.println("*** In the EXECUTE() method ****");
>>                System.out.println("The request object is : " + request);
>>
>>                ActionRequest aRequest =
>> PortletActionContext.getActionRequest();
>>                System.out.println("The Action request object is : " +
>> aRequest);
>>
>>                ActionResponse aResponse =
>> PortletActionContext.getActionResponse();
>>                System.out.println("The Action response object is : " +
>> aResponse);
>>
>>                aResponse.sendRedirect("http://www.google.lk");
>>
>>                return SUCCESS;
>>        }
>>
>> However, when I run this, The external URL is not loaded to the portlet
>> window. It says "undefined" within div tags.
>>
>> What should I do to make this work?
>>
>> Best Regards
>> Crishantha
>>
>> Nils-Helge Garli wrote:
>>>
>>> You can use the PortletResponseAware to get the portlet response object.
>>>
>>> Nnils-H
>>>
>>> On Sun, May 31, 2009 at 10:20 AM, Crishantha Nanayakkara
>>> <c....@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a requirement to use a response.sendRedirect() within my Action
>>>> class. Basically this action class is used to manipulate a porltet.
>>>>
>>>> Unlike Struts1, we do not directly have any processAction() method and
>>>> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>>>>
>>>> I just want to know how do we get about executing the
>>>> response.sendRedirect
>>>> with Struts2? What should be the interface to implement within the
>>>> action
>>>> class to do this. (Just like ServletRequestAware to get the
>>>> HttpServletRequest)
>>>>
>>>> Appriciate your help on this.
>>>>
>>>> Best Regards
>>>> Crishantha
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23806654.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23809082.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Unfortunately, you can't make an ajax request to the portlet. The ajax
tags are not supported in a portlet, due to limitations in the JSR168
specification. Also, I'm not quite sure what you're trying to do. Are
you attempting to load the div with Ajax with contents from a
different url? Have you considered using an iframe?

Nils-H

On Sun, May 31, 2009 at 10:32 PM, Crishantha Nanayakkara
<c....@gmail.com> wrote:
>
> Hi Nils-H,
>
> I got it working by using "ActionResponse aResponse =
> PortletActionContext.getActionResponse();" within the execute() method of
> the action event.
>
> Actually my main requirement is to redirect to an external URL within my
> portlet itself. For me to confine the external URL within the portlet
> window, I am using the Struts2 Ajax div tag within my jsp code.
>
> See the JSP code below,
>
> <sx:head debug="false" cache="false" compressed="false" />
>
> <s:url id="url" action="testUrl1" portletUrlType="action"/>
>
> <body>
>        <s:div id="div"/>
>        <s:submit value="Make Request" id="submit" />
>        <sx:bind targets="div" sources="submit" events="onclick"
> href="%{#url}" />
> </body>
>
> My execute() method looks like below,
>
>        public String execute() throws Exception {
>                System.out.println("*** In the EXECUTE() method ****");
>                System.out.println("The request object is : " + request);
>
>                ActionRequest aRequest =
> PortletActionContext.getActionRequest();
>                System.out.println("The Action request object is : " +
> aRequest);
>
>                ActionResponse aResponse =
> PortletActionContext.getActionResponse();
>                System.out.println("The Action response object is : " +
> aResponse);
>
>                aResponse.sendRedirect("http://www.google.lk");
>
>                return SUCCESS;
>        }
>
> However, when I run this, The external URL is not loaded to the portlet
> window. It says "undefined" within div tags.
>
> What should I do to make this work?
>
> Best Regards
> Crishantha
>
> Nils-Helge Garli wrote:
>>
>> You can use the PortletResponseAware to get the portlet response object.
>>
>> Nnils-H
>>
>> On Sun, May 31, 2009 at 10:20 AM, Crishantha Nanayakkara
>> <c....@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I have a requirement to use a response.sendRedirect() within my Action
>>> class. Basically this action class is used to manipulate a porltet.
>>>
>>> Unlike Struts1, we do not directly have any processAction() method and
>>> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>>>
>>> I just want to know how do we get about executing the
>>> response.sendRedirect
>>> with Struts2? What should be the interface to implement within the action
>>> class to do this. (Just like ServletRequestAware to get the
>>> HttpServletRequest)
>>>
>>> Appriciate your help on this.
>>>
>>> Best Regards
>>> Crishantha
>>> --
>>> View this message in context:
>>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23806654.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Crishantha Nanayakkara <c....@gmail.com>.
Hi Nils-H,

I got it working by using "ActionResponse aResponse =
PortletActionContext.getActionResponse();" within the execute() method of
the action event.

Actually my main requirement is to redirect to an external URL within my
portlet itself. For me to confine the external URL within the portlet
window, I am using the Struts2 Ajax div tag within my jsp code. 

See the JSP code below,

<sx:head debug="false" cache="false" compressed="false" />

<s:url id="url" action="testUrl1" portletUrlType="action"/>

<body>
        <s:div id="div"/>
        <s:submit value="Make Request" id="submit" />
        <sx:bind targets="div" sources="submit" events="onclick"
href="%{#url}" />
</body>

My execute() method looks like below,

        public String execute() throws Exception {
                System.out.println("*** In the EXECUTE() method ****");
                System.out.println("The request object is : " + request);

                ActionRequest aRequest =
PortletActionContext.getActionRequest();
                System.out.println("The Action request object is : " +
aRequest);

                ActionResponse aResponse =
PortletActionContext.getActionResponse();
                System.out.println("The Action response object is : " +
aResponse);

                aResponse.sendRedirect("http://www.google.lk");

                return SUCCESS;
        }

However, when I run this, The external URL is not loaded to the portlet
window. It says "undefined" within div tags. 

What should I do to make this work? 

Best Regards
Crishantha

Nils-Helge Garli wrote:
> 
> You can use the PortletResponseAware to get the portlet response object.
> 
> Nnils-H
> 
> On Sun, May 31, 2009 at 10:20 AM, Crishantha Nanayakkara
> <c....@gmail.com> wrote:
>>
>> Hi,
>>
>> I have a requirement to use a response.sendRedirect() within my Action
>> class. Basically this action class is used to manipulate a porltet.
>>
>> Unlike Struts1, we do not directly have any processAction() method and
>> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>>
>> I just want to know how do we get about executing the
>> response.sendRedirect
>> with Struts2? What should be the interface to implement within the action
>> class to do this. (Just like ServletRequestAware to get the
>> HttpServletRequest)
>>
>> Appriciate your help on this.
>>
>> Best Regards
>> Crishantha
>> --
>> View this message in context:
>> http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23806654.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: response.sendRedirect() with Struts2 within a portlet

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
You can use the PortletResponseAware to get the portlet response object.

Nnils-H

On Sun, May 31, 2009 at 10:20 AM, Crishantha Nanayakkara
<c....@gmail.com> wrote:
>
> Hi,
>
> I have a requirement to use a response.sendRedirect() within my Action
> class. Basically this action class is used to manipulate a porltet.
>
> Unlike Struts1, we do not directly have any processAction() method and
> ActionRequest and ActionResponse objects to do a response.sendRedirect.
>
> I just want to know how do we get about executing the response.sendRedirect
> with Struts2? What should be the interface to implement within the action
> class to do this. (Just like ServletRequestAware to get the
> HttpServletRequest)
>
> Appriciate your help on this.
>
> Best Regards
> Crishantha
> --
> View this message in context: http://www.nabble.com/response.sendRedirect%28%29-with-Struts2-within-a-portlet-tp23800916p23800916.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org