p:remoteCommand and p:fileDownload

UI Components for JSF
Post Reply
holek
Posts: 31
Joined: 18 Oct 2011, 16:23

31 Oct 2011, 12:11

Hi,

I have problem with p:fileDownload, after file is downloaded p:remoteCommand is not working :

Code: Select all

<p:remoteCommand name="nextView" update="form:tabView" process="form:tabView" oncomplete="if(!args.validationFailed ) {dosomething()}" />
<p:tabView id="tabView" onTabChange="nextView(); return false;" dynamic="true">
........

<p:commandLink ajax="false" style="float: left;" value="download font">
     <p:fileDownload value="#{bean.font}" />
</p:commandLink>
log in browser console:
Uncaught TypeError: Cannot read property 'validationFailed' of undefined
Resource interpreted as Document but transferred with MIME type application/pdf.
I think it is a bug, but remoteCommand or fileDownload bug ?

it works when i remove submit param added by fileDownload before using remoteCommand:

Code: Select all

<p:tabView id="tabView" onTabChange="$('.ui-submit-param').remove();nextView(); return false;" dynamic="true">
should remoteCommand send only form:tabView when there is process="form:tabView" ? and not '.ui-submit-param' ?

is there any way to open new browser window when downloading file instead of sending current page ?


primefaces 3.0.M4, Glassfish 3.1.1

Didjit
Posts: 3
Joined: 29 May 2015, 18:40

21 Oct 2015, 17:54

I'm having a similar issue in that I too am seeing the warning "Resource interpreted as Document but transferred with MIME type application/zip:" after triggering fileDownload. Here's the stripped-down version of what I'm doing:

Code: Select all

<p:commandButton id="downloadBtn" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(blockUI,releaseUI)">
    <p:fileDownload value="#{hierarchy.exportHierarchyAsStream()}" contentDisposition="attachment"/>	                
</p:commandButton>

Code: Select all

public StreamedContent exportHierarchyAsStreamedContent() {
    final PipedInputStream  inPipe  = new PipedInputStream();
    final PipedOutputStream outPipe = new PipedOutputStream(inPipe);
    StreamedContent stream = new DefaultStreamedContent(inPipe, "application/zip", "filename.zip");
    File tempFile = writeZipFile();
    Files.copy(FileSystems.getDefault().getPath(tempFile.getPath()), outPipe);							
    return stream;
}
I normally wouldn't worry much about this, except that a customer is having trouble with this. It looks like their connection is being closed from the client side after a minute. I'm wondering whether a paranoid router could be killing the connection because of this discrepancy. (Either that or it's a timeout issue. Is there a way to force keepAlive or connectionTimeout on the client side?)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests