Forum OpenACS Development: Unique constraint violation after using back button

Sometimes my users create an object from a form, click the back button, and re-use the form. This does not increment the object_id sequence so when they submit, they get this error:

duplicate key value violates unique constraint "acs_objects_context_object_un"

I realize generating the object_id in advance is part of double click protection but is there a way to trigger a new request when the back button is used?

Collapse
Posted by Ryan Gallimore on
This looks like a Firefox problem. The cache control headers are not being respected so the page is not reloaded with a new sequence number.

See http://support.mozilla.com/en-US/questions/707144

Firefox diverges from other browsers with the philosophy that the back button should display a page as it was originally requested.

For this reason the sequence does not increment and the unique constraint error occurs.

Has anyone encountered a solution for this?

Collapse
Posted by Torben Brosten on
Hi Ryan,

Is the form dual purpose update/create? If so, it seems that the intent needs to be distinguished by choosing a different button (new or update) to allow the form processing to confirm if form is expected to create a new object or use existing reference.

If the form's purpose is just to create, then one could check the time signature between the last time the key_value was used and the current time. If the time is within a few seconds, then it's a doubclick.. handle appropriately (ignore etc), otherwise grab another key and post as new..

cheers,

Torben

Collapse
Posted by Ryan Gallimore on
The form is create only. Good suggestion, I will give it a try.

Thanks, Torben.