Jan Bouchner
Jan Bouchner

Reputation: 897

JSF 2 and file download with command button - problems with final redirect?

I want to have a possibility to download .txt file in my JSF application. I use h:command button this way:

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

I use this methods in backing bean: http://pastebin.com/BMAQSgTJ (that implementation is probably ok because server returns me that file I want to download - it is possible to see in firebug output, i paste it only if you were interested)

My problem is that when I "click" on h:commandButton to download file, there is no dialog window to save or open file... does anybody know where is the problem?

This is my firebug output: http://dl.dropbox.com/u/21435926/firebug.png

Upvotes: 0

Views: 969

Answers (1)

JScoobyCed
JScoobyCed

Reputation: 10413

You might want to replace the AJAX actionListener in

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

to an action:

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

Upvotes: 1

Related Questions