2016-02-12 125 views
0

我学习了Tapestry版本5.在那里我建立了一个treemodel,它提供目录中的文件。挂钩保存文件对话框

<t:tree t:id="tree" t:model="stuffModel" t:node="treeNode" t:value="classificationNode"> 
    <p:label> 
    <t:if test="treeNode.leaf"> 
    <a t:type="EventLink" t:event="leafSelected" t:context="classificationNode.name" t:zone="selectedZone" class="prop:leafClass" href="#"> ${treeNode.label} </a> 
    </t:if> 
    <t:if test="!treeNode.leaf"> 
      ${treeNode.label} 
    </t:if> 
    </p:label> 

点击我建立一个StreamResponse中的一个文件(我从那么JumpStart代码中使用的片段(页:http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntypes1

我的问题,我的问题是我怎么呈现保存文件对话框,这将有助于用户指向下载文件夹。 为了真正下载文件,我必须右键单击然后选择“保存文件为...”?

回答

-1

添加到您的代码

{ 
    public partial class Form1 : Form 
    { 
    public Form1() 
    { 
     InitializeComponent(); 
    } 

    private void button1_Click(object sender, EventArgs e) 
    { 
     // When user clicks button, show the dialog. 
     saveFileDialog1.ShowDialog(); 
    } 

    private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) 
    { 
     // Get file name. 
     string name = saveFileDialog1.FileName; 
     // Write to the file name selected. 
     // ... You can write the text from a TextBox instead of a string literal. 
     File.WriteAllText(name, "test"); 
    } 
    } 
} 
+0

对不起,队友,它不是C#。这是Java和Tapestry的问题 – hephestos