p:fileDownload

UI Components for JSF
Post Reply
icordoba
Posts: 67
Joined: 20 Nov 2010, 19:20

21 Nov 2010, 22:30

Hello,
it's only days I've embraced PrimeFaces and I am impressed with this library. Could not be happier!
Now a small problem I'm facing... I'm trying to use p:fileDownload in a p:dataTable to download one of files. I do the following:

Code: Select all

<p:commandButton title="#{msgs.download}" image="ui-icon-circle-arrow-s" action="#{afonicUserView.downloadAudio(box)}" ajax="false" immediate="true">
    <p:fileDownload value="#{afonicUserView.streamedContent}"/>
</p:commandButton>
The problem is that the getStreamedContent() is invoked before the downloadAudio() method, so I get an exception as the managed bean has not yet prepared the stream.
Can I make downloadAudio() method be invoked first? If not... what can be the approach to do the traditional "download" link in a dataTable?

thanks for any help,
Ignacio

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

21 Nov 2010, 23:23

Hi,

Welcome to PrimeFaces!

action is executed after actionListeners which fileDownload is so you need to use an actionListener to create your content;

Code: Select all

actionListener="#{afonicUserView.downloadAudio(box)}" 

icordoba
Posts: 67
Joined: 20 Nov 2010, 19:20

22 Nov 2010, 01:04

OOOps. Thanks a lot. Worked ok.

User avatar
mattball
Posts: 4
Joined: 06 Dec 2010, 22:17

09 Dec 2010, 01:46

Ignacio, would you mind posting the Java and XHTML code that you used to get this working? I've been pulling my hair out trying to get fileDownload to work inside of a dataTable, and it looks like you have it solved. I created a thread on the issue but haven't had any responses so far: http://primefaces.prime.com.tr/forum/vi ... f=3&t=6547. I'd be much obliged if you have any help to offer.
PrimeFaces 2.2 RC2
Mojarra 2.0.2
GlassFish 3.01

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 90 guests