Some info on built-in key handling and therefore potentially useful in building double-click protected forms.
From the OpenACS ad_form documentation here:
https://openacs.org/api-doc/proc-view?proc=ad%5fform
"ad_form defines a "key" pseudotype. Only one element of type "key" is allowed per form, and it is assigned the integer datatype. Only keys which are generated from a database sequence are managed automatically by ad_form. If the sequence name is not specified, the sequence acs_object_id_seq is used to generate new keys. Examples:
my_key:key
Define the key "my_key", assigning new values by calling acs_object_id_seq.nextval
my_key:key(some_sequence_name)
Define the key "my_key", assigning new values by calling some_sequence_name.nextval"
AND
"Here's an example of a simple page implementing an add/edit form:
ad_page_contract {
Simple add/edit form
} {
my_table_key:optional
}
ad_form -name form_name -export {foo {bar none}} -form {
my_table_key:key(my_table_sequence)
{value:text(textarea) {label "Enter text"}
{html {rows 4 cols 50}}}
} -select_query {
select value from my_table where my_table_key = :my_table_key
} -validate {
{value
{[string length $value] >= 3}
"\"value\" must be a string containing three or more characters"
}
} -new_data {
db_dml do_insert "
insert into my_table
(my_table_key, value)
values
(:key, :value)"
} -edit_data {
db_dml do_update "
update my_table
set value = :value
where my_table_key = :key"
} -after_submit {
ad_returnredirect "somewhere"
ad_script_abort
}
In this example, ad_form will first check to see if "my_table_key" was passed to the script. If not, the database will be called to generate a new key value from "my_table_sequence" (the sequence name defaults to acs_object_id_seq). If defined, the query defined by "-select_query" will be used to fill the form elements with existing data (an error will be thrown if the query fails).
"