掲示板

sendRedirects not working

thumbnail
10年前 に Dave Weitzel によって更新されました。

sendRedirects not working

Regular Member 投稿: 208 参加年月日: 09/11/18 最新の投稿
I am trying to "hand off" the user from m y own portlet to the shopping cart so that they can pay for an item my portlet has put into their cart in the background.

I am trying to do this by using actionResponse.sendRedirect(redirectURL)

However even though I am creating a valid url by:
a) detect edfault PLid:
LayoutLocalServiceUtil.getDefaultPlid(groupId, false , "34");

b) create PortletURL:
LiferayPortletURL lcartURL = PortletURLFactoryUtil.create(actionRequest, shoppingPid , defPlid, "0");

c) adding some properties:
String addProps= "&_34_struts_action=/shopping/cart&p_p_state=maximized";

d) combining
String redirectURL= lcartURL.toString() + addProps;

e) send the redirect
actionResponse.sendRedirect(redirectURL);

It will not redirect there and just returns to the final page of my portlet.
I can trace the url and cut and paste it in to that users window and it displays fine so the URL is OK but for some reason not visible in eclipse console the redirect isnot working?

Any advice?
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: sendRedirects not working

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
For item (c), shouldn't you be using lcartURL.setParameter() to set the parameters rather than manually appending them on the end?
thumbnail
10年前 に Dave Weitzel によって更新されました。

RE: sendRedirects not working

Regular Member 投稿: 208 参加年月日: 09/11/18 最新の投稿
Thanks David but it doesn't affect the behavior at all (I tried that approach first!)

I have found the answer though. In the original request we have a redirect parameter (as sees to be standard practice).

If that exists it seems that actionResponse.sendRedirect(redirectURL); will not go to the redirectURl you specify but will go to the redirect parameter in the request,

I have renamed my parameter redirectFail (as that is what it really was for) and everything started working like magic.

Not got time to try other variants of this workaround.