Thanks Nagaev and Wim.  

Yeah, I'm currently using a QueryModel to query the database.

I was thinking about this all wrong (thinking like a desktop developer).  I had 
a File->Export CSV menu option that was connected to a slot.  I thought I'd 
write the code in the slot to generate the CSV, show a file dialog, and somehow 
Save to Remote Disk.  It sounds like the thing I was missing is that I need to 
start with a WAnchor to trigger the file download, hook it up to a WResource of 
some type, then generate the CSV inside of that stack someplace (depending on 
the class I use).

Now that my thinking has been flipped around, I'll take a look at those classes 
and see which one will work best.

Craig




Sounds like I should:

1.  Write a short method to generate the CSV to disk.
2.  Use WFileResource to fetch the CSV.
3.  Delete the CSV from disk.

Pretty straight forward.

Craig Miller
http://spatialminds.com



On Sep 19, 2012, at 1:28 AM, Wim Dumon wrote:

> In addition, you could write a small piece of code that reads from a
> Wt model and writes out CSV files. Then use a QueryModel to query your
> database and write out csv files.
> 
> Wim.
> 
> 2012/9/19 Nagaev Boris <bnag...@gmail.com>:
>> Hello!
>> 
>> I think class WResource is what you are looking for. Connect WAnchor
>> to it and set mime type to something save-able (as opposed to
>> view-able). This results in default file save dialog of browser. I do
>> not know if this dialog can be customised.
>> 
>> http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WResource.html
>> 
>> Implement generation of CSV inside handleRequest() method. Stream
>> output lines of CSV file to response.out() stream.
>> 
>> This works good for small files. If you file is large or its
>> generation is resource resource intensive, consider using
>> WStreamResource (with implementing your own istream, producing CSV
>> lines) or WFileResource (with pre-saving whole file to disk).
>> 
>> 
>> On Wed, Sep 19, 2012 at 4:26 AM, Craig Miller
>> <craig.mil...@spatialminds.com> wrote:
>>> I'm trying to implement what I believe is a fairly straight-forward 
>>> use-case, but I can't seem to find the right classes to implement a 
>>> solution.
>>> 
>>> The use-case is to export a CSV of the current Dbo model and save it to the 
>>> users computer.
>>> 
>>> - Are there any utility classes already in existence to help me create a 
>>> virtual CSV file?
>>> - Is there a Wt File Save Dialog class?
>>> 
>>> Thanks,
>>> Craig
>>> 
>>> Craig Miller
>>> http://spatialminds.com
>>> 
>>> 
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> witty-interest mailing list
>>> witty-interest@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>> 
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> witty-interest mailing list
>> witty-interest@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> witty-interest mailing list
> witty-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/witty-interest


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to