Update component after file download

后端 未结 3 460
不知归路
不知归路 2020-12-05 15:41

I\'m using Primefaces TabView, CommandButton and FileDownload to download a log file. Once the log file has been downloaded, I want to offer the option to delete the content

相关标签:
3条回答
  • 2020-12-05 16:20

    Have you tried changing eventLogExported/isEventLogExported from boolean to Boolean or String ?

    0 讨论(0)
  • 2020-12-05 16:30

    p:commandButton in your case is (an has to be) non-AJAX button (you set this by adding ajax="false" attribute). In that case update attribute and p:ajax tag doesn't have any sense (as they are only for AJAX requests). When you have file download your application sends streaming of some type, and you see Save File dialog. Your page is not refreshed. So you have to use PrimeFaces.monitorDownload to do this:

    <p:commandButton id="exportEventLogButton" 
                     icon="ui-icon-disk" 
                     styleClass="c25" 
                     ajax="false" 
                     title="Export Log" 
                     disabled="#{empty managedCmsLogsBean.eventLogEntityList}"
                     onclick="PrimeFaces.monitorDownload(null, stop)">
    

    and add stop function which will update second button:

    <p:remoteCommand name="stop" update="deleteEventLogButton"/>
    
    0 讨论(0)
  • As Balusc answered, In question (revisions) , we cannot get response twice from a single request, to refresh a page after download, better use the following java script in download link(p:commandbutton) onclick tag.

    Example:

    <p:commandButton ajax="false" icon="ui-icon-arrowstop-1-s" onclick="setTimeout('location.reload();', 1000);" action="#{managedBean.downloadMethod}" />
    

    this will automatically refresh the page after 1 second, at the same time i.e. before refresh, you will get the download file, based on your download response time, increase the seconds in that script. Seconds should not less than that download response time.

    0 讨论(0)
提交回复
热议问题