IOWA -- another newbie question

M

Mark Probert

What is the best way of implemting a "Save file" button in IOWA?

I have a form of data that I generate and I want to save it to the client's
machine. Copy and paste, or "Save" from the browser are not really what I
am after here, rather a file transfer kind of option.

TIA,
 
K

Kirk Haines

What is the best way of implemting a "Save file" button in IOWA?

I have a form of data that I generate and I want to save it to the
client's machine. Copy and paste, or "Save" from the browser are
not really what I am after here, rather a file transfer kind of option.

Hmmm. Disclaimer: I haven't had enough sleep. :)

Here's my initial inclination:

-----

<input type="submit" value="Save File" oid="saveFile">

-----

def saveFile
newPage = pageNamed('MyFormData')
newPage.attribute1 = @attribute1
newPage.attribute2 = @attribute2
#
# And so on, setting whatever you need to generate the data that
# you want to save.
#
yield newPage
end
-----

Now, you have a MyFormData.html and a MyFormData.iwa. Do it just like you
would a regular web component, except, of course, this component is intended
to be saved by the browser. You are creating your downloaded file, here.

In MyFormData.iwa:

def setup
req = session.context.request
# Set an appropriate content type.
req.content_type = 'application/octet-stream'
# And set your filename.
req.headers_out['Content-Disposition'] = 'attachment; filename="my.dat"'
end


Your browser should simply download whatever MyFormData generates, now. I
am doing something similar in a few apps in order to generate downloaded CSV
dumps of report contents.


Hope that helps,

Kirk Haines
 
M

Mark Probert

Kirk Haines said:
Hmmm. Disclaimer: I haven't had enough sleep. :)
Perfect! Thanks, Kirk.

Another question. Is there any callback mechanism from a select box, radio
button, etc?

Currently, I am doing:

<b>Select Set</b>
<select oid="fullSet"><option oid="userset"> </select>
<input type="submit" oid="limit" value="Limit"/>

So they select the subset and hit the 'Limit' button.
I'd like to be able to trigger directly off the dropdown, if possible.

Many thanks, once again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top