Hi,
I have the same problem. I am wondering if there is any solution for this (if there
is one and no one responded for so long I will still wonder). I think when we
assign
a FileOutputStream to a CSpStringOutputStream, the browser does not care to
ask for
the file name again. If you do not assign a FileOutputStream to the
CSpStringOutputStream,
I noticed the browser asks what to do with the content (if it can not
understand
the content). As a side effect of asking for action, we get to choose the
file name
(when 'Save As' is chosen). I do not know if this is stretching the logic too
far
(I do it when I could not get something working in a reasonable amount of
time).
Gurus, please help (Anisha Vaswani: if you received any answer to your posting
privately, please mail it to me).
Thanks in advance,
Bhaskara Reddy.
"Vaswani, Anisha" <[EMAIL PROTECTED]> wrote:
>Hi NetD Gurus,
>
>I need to build in functionality that allows users to download a
>pipe-delimited text file which s dynamically created based on the query
>parameter(s) they specify. Most of the code works fine (thanks to all the
>tips on the forum), but I can't get the "Save AS" dialog box to pop up for
>download. If I hard-code the path, the file is created and downloaded
>correctly. I've tried using CSpHttp.writeContentType() but it doesn't do
>anything. Can anyone tell me what I'm doing wrong?
>
>Here is the code:
>
>*********************************************************
>public int cbDownload_onWebEvent(CSpWebEvent event)
>{
> int command = PROCEED;
> boolean succeeded = true;
> CSpStringOutputStream diskFile = null;
> String fileName = "c:\\temp\\testND.txt";
> File file = new File (fileName);
> CSpStringOutputStream origOutputStream =
>CSpider.getOutputStream();
> CSpHttp.reset ();
> CSpHttp.setAutoMode (false);
> try
> {
> diskFile = new CSpStringOutputStream (new FileOutputStream
>(file));
> CSpider.setOutputStream(diskFile);
> CSpSelect getDR = (CSpSelect) CSpider.getDataObject("doSelectDR");
> getDR.clearAllValues();
> getDR.clearDynamicCriteria();
> String whereStr = "dradmin.design_reg.dr_status = \"" +
>getDisplayFieldValue("cmbDRStatus").stringValue() + "\"";
> getDR.addDynamicStrCriterion(whereStr);
> getDR.execute();
> CSpHttp.writeContentType(diskFile, "text/octet-stream");
>//***Doesn't do anything
> for (int i = 0; i <getDR.getNumOfRows (); i++)
> {
> diskFile.write(getDR.getValue(i,
>"design_reg_id").stringValue() + "|");
> diskFile.write(getDR.getValue(i,
>"distributor_id").stringValue() + "|");
> diskFile.write(getDR.getValue(i,
>"distributor_name").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"branch_id").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"acct_master_name").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"part_number").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"acct_zip").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"dr_submitted_by").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"dr_submit_date").stringValue() + "|" );
> diskFile.write(getDR.getValue(i,
>"design_win_flag").stringValue() + "|" + "\n");
> }
>
> CSpHtml.flush (diskFile);
>
> }
> catch (Exception ex)
> {
> succeeded = false;
>
> }
> finally
> {
> CSpider.setOutputStream(origOutputStream);
> if (diskFile != null)
> {
> try
> {
> diskFile.close();
> }
> catch (IOException ex)
> {
> succeeded = false;
> }
> }
> }
> CSpHttp.reset ();
> if (succeeded)
> {
> //CSpHtml.sendMessage("Download Succeeded! <BR>");
> }
> else
> {
> //CSpHtml.sendMessage("Download Failed! <BR>");
> }
> return (load("pgTestDownload"));
>}
> //]]SPIDER_EVENT<cbDownload_onWebEvent>
>
>**********************************************************************
>TIA,
>Anisha
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]