Hola
Tengo el siguiente caso, tengo un botón con un Download que descargar un fichero desde un servidor.
En el constructor de la clase tengo:
StreamResource sr = getExcelStream();
FileDownloader fileDownloader = new FileDownloader(sr);
fileDownloader.extend(btExcel);
Siendo getExcelStream();
private StreamResource getExcelStream() {
StreamResource.StreamSource source = new StreamResource.StreamSource() {
private static final long serialVersionUID = -1413114720868341991L;
public InputStream getStream() {
Notification notif = null;
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
String contenido = l[b]
oadTable(true);
[/b]
if (contenido.isEmpty()){
notif = null;
UI.getCurrent().markAsDirtyRecursive();
notif = new Notification(traductor.getTranslation(“cosmsexportKO”), Type.ERROR_MESSAGE);
notif.setDelayMsec(2000);
notif.show(UI.getCurrent().getPage());
UI.getCurrent().markAsDirtyRecursive();
return null;
}
stream.write(Base64.decodeBase64(contenido));
InputStream input = new ByteArrayInputStream(stream.toByteArray());
return input;
} catch (Exception e) {
notif = null;
UI.getCurrent().markAsDirtyRecursive();
notif = new Notification(traductor.getTranslation(“cosmsexportKO”), Type.ERROR_MESSAGE);
notif.setDelayMsec(2000);
notif.show(UI.getCurrent().getPage());
UI.getCurrent().markAsDirtyRecursive();
return null;
}
}
};
StreamResource resource = new StreamResource ( source, “listadocontratos.xls”);
return resource;
}
El código puede estar mejor, pero no es el caso…
El problema es el siguiente, quiero que cuando llame al método:
loadTable(true);
se muestre una Notification que diga que se está bajando el fichero (
raductor.getTranslation(“cosmsexportKO”),
pero el problema es que hasta que no sale del método
getExcelStream(
) no lo hace.
Por más que he probado a poner el código de mostrar el mensaje en el Button.ClickListener… poner el markAsDirty… no he logrado hacerlo… ¿Alguien tiene alguna idea?
Un saludo