Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Pedro Almeida
Clearing actionRequest parameters
2 ottobre 2012 9.37
Risposta

Pedro Almeida

Punteggio: Junior Member

Messaggi: 41

Data di Iscrizione: 30 luglio 2012

Messaggi recenti

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.
David H Nebinger
RE: Clearing actionRequest parameters
2 ottobre 2012 10.02
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11492

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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.
Sampsa Sohlman
RE: Clearing actionRequest parameters
2 ottobre 2012 10.32
Risposta

Sampsa Sohlman

LIFERAY STAFF

Punteggio: Regular Member

Messaggi: 225

Data di Iscrizione: 27 settembre 2007

Messaggi recenti

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
RE: Clearing actionRequest parameters
3 ottobre 2012 3.25
Risposta

Pedro Almeida

Punteggio: Junior Member

Messaggi: 41

Data di Iscrizione: 30 luglio 2012

Messaggi recenti

found a solution here

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

it works! thanks!
Sampsa Sohlman
RE: Clearing actionRequest parameters
4 ottobre 2012 3.46
Risposta

Sampsa Sohlman

LIFERAY STAFF

Punteggio: Regular Member

Messaggi: 225

Data di Iscrizione: 27 settembre 2007

Messaggi recenti

1You can configure this in liferay-portlet.xml file.
2
3check 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
RE: Clearing actionRequest parameters
4 ottobre 2012 8.56
Risposta

Pedro Almeida

Punteggio: Junior Member

Messaggi: 41

Data di Iscrizione: 30 luglio 2012

Messaggi recenti

Sampsa Sohlman:
1You can configure this in liferay-portlet.xml file.
2
3check 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!