First off, I just registered for this forum today. There seems to be a lot of knowledge
Struts developers here and I have learned a few things looking around. Okay enough flattery...I saw the "Preventing multiple posts" FAQ entry and I wanted to ask a related question. This was an issue that I tried to solve a year or two ago, so my memory is a little rusty. BTW, I am (still) using Struts 1.1.
I wanted to hook up code to prevent multiple submissions. It seemed to work initially, but popup windows caused it to fail. When I say "popup windows" I am referring to an example such as a page where you can edit a person and when you click a link there is a popup window where you can edit a list of phone numbers. That is not a real example, but my project has a number of these popup windows.
So the flow is that the user is at the base edit page. This page is rendered with a TOKEN of "AAA". They click the link to bring up the child popup window. This page is rendered with a TOKEN of "BBB". The user clicks the Save button on the popup window and the call to isTokenValid works correctly. Now the user is back to the base page and they click the Save button. This time the call to isTokenValid fails because this page is submitted with a TOKEN of "AAA" but the popup window set the value on the session to "BBB".
Has anybody else had to deal with this issue? If so, how did you solve it?
BTW, one thing that I did that seemed like a good idea...well if the other part was working. I create a custom class derived from RequestActionMapping and added a property named synchronize that defaults to false. I then only set this to true for actions such as saves. In my base action class, I check this property and only call isTokenValid when it is true.
- Brent
(Edited to clarify text)
[ November 01, 2006: Message edited by: Brent Sterling ]