JSF 2和带命令按钮的文件下载 - 最终重定向的问题?

时间:2012-04-06 14:51:03

标签: jsf download firebug

我希望有可能在我的JSF应用程序中下载.txt文件。我用这种方式使用h:command按钮:

<h:commandButton value="Download" actionListener="#{exportBean.downloadFile}">
<f:attribute name="fileName" value="#{upload.name}"/>
</h:commandButton>

我在支持bean中使用这个方法:http://pastebin.com/BMAQSgTJ(该实现可能没问题,因为服务器返回我想要下载的文件 - 可以在firebug输出中看到,我只有在你感兴趣时才粘贴它)

我的问题是当我“点击”h:commandButton下载文件时,没有保存或打开文件的对话窗口......有人知道问题在哪里吗?

这是我的萤火虫输出:http://dl.dropbox.com/u/21435926/firebug.png

1 个答案:

答案 0 :(得分:1)

您可能想要替换

中的AJAX actionListener
<h:commandButton value="Delete file" actionListener="#{exportBean.deleteFile}">

action

<h:commandButton value="Delete file" action="#{exportBean.deleteFile}">