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,
···
--
-mark. (probertm @ acm dot org)
Hmmm. Disclaimer: I haven't had enough sleep. 
Here's my initial inclination:
···
On Thu, 2 Sep 2004 12:15:21 +0900, Mark Probert wrote
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.
-----
<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
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.
···
"Kirk Haines" <khaines@enigo.com> wrote:
Hmmm. Disclaimer: I haven't had enough sleep. 
--
-mark. (probertm @ acm dot org)