p: fileDownload Simulate click from event rowDblselect in p: dataTable

0

I am working with Primefaces. I explain my problem, to see if you can lend me a hand. I have a table with a list of documents that are stored in Sharepoint. In the table I have a button to download the documents.

<p:commandButton 
    id="botonDescargarDocumento"
    value="#{msg['comun.boton.descargar']}"
    actionListener="#{seguimientoExpsManagedBean.descargarDocumento}"
    ajax="false">
    <p:fileDownload
        value="#{seguimientoExpsManagedBean.ficheroDescarga}" />
</p:commandButton>

By clicking on the button you access Sharepoint and the corresponding document is downloaded without any problem. Until here well.

Now what I want is to translate this same functionality to the rowDblselect event of the <p:dataTable> component. That is, I want to double click on the record of the document that is in the table, call the same download method of the download button listener and download the corresponding file in the same way you do when you click on the button. I hope you have explained to me.

Thank you very much !!

Greetings.

    
asked by user3270931 11.10.2016 в 13:01
source

1 answer

0

How about, I can think of a solution a bit dirty and I'm not sure what functions, primefaces tells us that file download requests can not be asynchronous and what you want to do is achieved by using the ajax tag inside the dataTable, so I can think of the following:

 <p:dataTable id="idDataTable">
      <p:ajax event="rowDblselect" 
         onComplete="document.getElementById('form:botonDescargarDocumento').click();">
 </p:dataTable>

In theory, a click on the corresponding download button would be simulated, I hope it works for you.

Greetings.

    
answered by 11.10.2016 в 20:32