jsfprimefacesicefaces

Primefaces fileDownload JavaScript Error


I'm trying to Download a File with the Primefaces fileDownload component. Unfortunately it is not working. I only get an Javascript Error "[window] the response does not contain XML data"

I am using JSF 2.1.6 with Primefaces 3.2, IceFaces Push version 2.0.2 is used to Push data, and some Spring Functions with Spring Version 3.1.0. All Running on a Tomcat 6.0.33.

A Snippet of my xHtml Code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
<h:body>
 <p:layout> 
   ...
   <p:layoutUnit id="east" ... >
     <h:form id="eForm">
       <p:dataTable ... >
         ...
           <p:row >
             <p:column style="font-weight: bold;">Attach 1:</p:column>
               <p:column>
                 <p:commandLink id="attach1" value="Download" ajax="false" immediate="true">
                      <p:fileDownload value="#{data.file}" />
                    </p:commandLink> 
                  </p:column>
                </p:row>
       </p:dataTable>
     </h:form>
    ...
 </p:layout>
</h:body>

The FileDownload Bean

@ManagedBean(name = "data")
@RequestScoped
public class FileDownload {

private StreamedContent file;

public FileDownload() {
    InputStream stream = ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/resources/images/phone_speaker_x24.png");
    file = new DefaultStreamedContent(stream, "image/jpg", "downloaded_optimus.jpg");
}

public StreamedContent getFile() {
    return file;
}
}

The Error from FireBug

 [window] the response does not contain XML data  bridge...9208334 (Zeile 1217)
 [window] Error [status: emptyResponse code: 200]: An empty response was received from the server. Check server error logs.

There is no Error at the Tomcat Log

Edit

Icefaces is the Problem. Removing all Icefaces Libs the Download works fine. But no IceFaces no Push so.


Solution

  • Okey, Primefaces and IcePush don't allways work together. Removing the IceFaces Push from my Project made the Download work but no Push.

    So i decided to write the Push on my own and just use Primefaces.