2010-03-01 6 views

Répondre

1

Oui Il est possible de le faire au moins dans DWR 3.

0

Un exemple qui retourne un excel pour télécharger du client:

// côté Java:

public FileTransfer getExcel(Parametros param){ 
    byte[] result = <here get data>; 
    InputStream myInputStream = new ByteArrayInputStream(result); 
    String excelFormat = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 
    FileTransfer dwrExcelFile = new FileTransfer("excel.xlsx", excelFormat, myInputStream); 
    return dwrExcelFile; 
} 

// côté Javascript:

function downloadExcelFile() { 
    dwr.engine.setTimeout(59000); 
    var params = <params_to_send>; 
    <Java_class>.getExcel(params, {callback:function(dataFromServer) { 
    downloadExcelCallback(dataFromServer); 
    }}); 
} 

function downloadExcelCallback(data) { 
    dwr.engine.openInDownload(data); 
}