フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Dave Weitzel
sendRedirects not working
2013/04/11 11:59
答え

Dave Weitzel

ランク: Regular Member

投稿: 181

参加年月日: 2009/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?
David H Nebinger
RE: sendRedirects not working
2013/04/11 13:15
答え

David H Nebinger

ランク: Liferay Legend

投稿: 7064

参加年月日: 2006/09/01

最近の投稿

For item (c), shouldn't you be using lcartURL.setParameter() to set the parameters rather than manually appending them on the end?
Dave Weitzel
RE: sendRedirects not working
2013/04/16 12:17
答え

Dave Weitzel

ランク: Regular Member

投稿: 181

参加年月日: 2009/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.