struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils-Helge Garli Hegvik <nil...@gmail.com>
Subject Re: response.sendRedirect() with Struts2 within a portlet
Date Sun, 31 May 2009 21:13:33 GMT
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.nanayakkara@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.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message