Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pedro Almeida
Clearing actionRequest parameters
October 2, 2012 9:37 AM
Answer

Pedro Almeida

Rank: Junior Member

Posts: 41

Join Date: July 30, 2012

Recent Posts

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
October 2, 2012 10:02 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11047

Join Date: September 1, 2006

Recent Posts

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
October 2, 2012 10:32 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 225

Join Date: September 27, 2007

Recent Posts

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
October 3, 2012 3:25 AM
Answer

Pedro Almeida

Rank: Junior Member

Posts: 41

Join Date: July 30, 2012

Recent Posts

found a solution here

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

it works! thanks!
Sampsa Sohlman
RE: Clearing actionRequest parameters
October 4, 2012 3:46 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 225

Join Date: September 27, 2007

Recent Posts

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
October 4, 2012 8:56 AM
Answer

Pedro Almeida

Rank: Junior Member

Posts: 41

Join Date: July 30, 2012

Recent Posts

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!