Forum OpenACS Development: How to pass multiple integers via a hidden text-field

I'm trying to fix a bug in file-storage, but whatever I try doesn't do what I want it to do.

Here's the thing. When trying to delete multiple files at once (by clicking multiple checkboxes) only one file gets deleted. This is because by an error in delete.tcl only the object_id of one file makes it into the hidden textfield on the confirmation screen.

Solving that is easy I thought, and indeed having all object_id's appear, space separated, in the hidden form field was no problem.

However, now the formfield contains e.g. "623 645" (two object_id's) and when submitted, the scripts receives "{623 645}" (this is NOT a tcl list mind you - it's a string starting with { and ending with }, that's my problem).

Of course, the dirty way would be to just strip the accolades, but I guess there's a better way.

The contract is changed to:

ad_page_contract {
    delete items
} {
    object_id:notnull,multiple
    {confirm_p:optional,boolean 0}
    {return_url ""}
}

--> object_id used to be declared integer, but that doesn't work if you need to pass multiple values via a textfield.

When called from the folder-view (when you press delete) everything goes ok - multiple object_id variables with different values are passed and everybody's happy.

However, the confirmation screen is essentially a form, with all object_id's in a hidden text field. If you return to delete.tcl from the confirmation screen I end up the "{ ... }" problem.

Thanks in advance for any help.

Rgds,
Jeroen

Collapse
Posted by Janine Ohmer on
When I ran into this there wasn't really a good solution:

https://openacs.org/forums/message-view?message_id=116422

The best I can suggest is that on your confirmation page you take the string being passed in, split it into a list, and re-export it.  Unless someone has found a better way to handle this by now?

Collapse
Posted by Dave Bauer on
Janine has it right.

I fixed this btw. I just split the first element of the list if the length is 1. This seems to make it work for single or mutiple files.

There were several other errors in that the variable named "object_id" kept getting overwritten by the multirow. I used a unique name to solve that.