Fórum

Clearing actionRequest parameters

Pedro Almeida, modificado 11 Anos atrás.

Clearing actionRequest parameters

Junior Member Postagens: 41 Data de Entrada: 30/07/12 Postagens Recentes
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
David H Nebinger, modificado 11 Anos atrás.

RE: Clearing actionRequest parameters

Liferay Legend Postagens: 14915 Data de Entrada: 02/09/06 Postagens Recentes
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
Sampsa Sohlman, modificado 11 Anos atrás.

RE: Clearing actionRequest parameters

Regular Member Postagens: 230 Data de Entrada: 27/09/07 Postagens Recentes
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.
Pedro Almeida, modificado 11 Anos atrás.

RE: Clearing actionRequest parameters

Junior Member Postagens: 41 Data de Entrada: 30/07/12 Postagens Recentes
found a solution here

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

it works! thanks!
thumbnail
Sampsa Sohlman, modificado 11 Anos atrás.

RE: Clearing actionRequest parameters

Regular Member Postagens: 230 Data de Entrada: 27/09/07 Postagens Recentes
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.
Pedro Almeida, modificado 11 Anos atrás.

RE: Clearing actionRequest parameters

Junior Member Postagens: 41 Data de Entrada: 30/07/12 Postagens Recentes
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!