Forum OpenACS Development: Re: Res: Handling Double Submits...

Collapse
Posted by Jose Pablo Escobedo Del Cid on

I've had the very same problem before, and the only solution that have worked for me have been to add a "when not exists" in the insert statement. Like this:

insert into table (key_id)
(select (:key_id_var)
 where not exists
 (select 1 from table where key_id = :key_id))
or just
select create__new(:key_id)
where not exists (select 1 from table where key_id = :key_id)

I have tried other approaches, like generating the object_id in another page (a confirmation one, for instance), but there are allways some cases when it fails (if something can go wrong will go wrong ;o)

Of course a better approach would be to somehow improve the already existing API of the ad_form or the acs_objects to avoid this problem...

Collapse
Posted by Alex Kroman on
Maybe the right answer is just ditching duplicate detection? Every application I've used on the Internet will create a duplicate if you go back and submit the 'create new item' form again....