掲示板

Clearing actionRequest parameters

11年前 に Pedro Almeida によって更新されました。

Clearing actionRequest parameters

Junior Member 投稿: 41 参加年月日: 12/07/30 最新の投稿
Hello,

I am developing a portlet where I have process action methods that read parameters from the ActionRequest parameter.

I can read them properly, but if I refresh a page, the process action method is fired again, with the parameter still containing the previous value, even though it was not introduced again. I don't want this to be persistent, I only want it to last for that specific form submission.

Is there a direct way (programatically clearing) or indirect (configuration setup) to change this behaviour?

Thank you.
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: Clearing actionRequest parameters

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
I don't think this is possible.

The action params are part of the page sitting on the browser, so you don't have any real access to them to clear them out.
thumbnail
11年前 に Sampsa Sohlman によって更新されました。

RE: Clearing actionRequest parameters

Regular Member 投稿: 230 参加年月日: 07/09/27 最新の投稿
Pedro Almeida:
Is there a direct way (programatically clearing) or indirect (configuration setup) to change this behaviour?


As David did mention this happens on client side, and this is typical doublesubmit problem. You can do following to solve it.

When you render the page you can put there hidden field containing time value in milliseconds and save same time value in milliseconds to your portlet session. Before you read the values from action request, read this hidden field value containing millis and compare that to your value to value from portlet session. If the values are match read the rest and do the business logic, if the values are not match ignore action request values and you can show also warning or error message.
11年前 に Pedro Almeida によって更新されました。

RE: Clearing actionRequest parameters

Junior Member 投稿: 41 参加年月日: 12/07/30 最新の投稿
found a solution here

http://www.liferay.com/community/forums/-/message_boards/message/16700678

it works! thanks!
thumbnail
11年前 に Sampsa Sohlman によって更新されました。

RE: Clearing actionRequest parameters

Regular Member 投稿: 230 参加年月日: 07/09/27 最新の投稿
You can configure this in liferay-portlet.xml file.

check action-url-redirect attribue


Actually, that does not protect on all cases. The case that your user is pressing button twice very fast and network is little bit slow. So if you are billing customer when he is clicking the button and you want to avoid double billing all cases use solution that I did describe above.
11年前 に Pedro Almeida によって更新されました。

RE: Clearing actionRequest parameters

Junior Member 投稿: 41 参加年月日: 12/07/30 最新の投稿
Sampsa Sohlman:
You can configure this in liferay-portlet.xml file.

check action-url-redirect attribue


Actually, that does not protect on all cases. The case that your user is pressing button twice very fast and network is little bit slow. So if you are billing customer when he is clicking the button and you want to avoid double billing all cases use solution that I did describe above.


good point! thanks!