Hi all,
I’m having a issue BrowserWindowOpener/FileDownloader(same behavior). I have a table where a choose a patient and create a pdf. The first time a do this no problem. Everything is ok. The pdf is created ok.
The second time i want to generate a pdf (same o other patient) i’ve got my pdf but also got the firt pdf and so on.
I don’t know what can be happening but the it’s like the previus pdf still some where.
This is some snippet code:
if(event.getSource() == this.getBtnGenerarReporte()){
// Resource resource, bwo BrowserWindowOpener
//paciente object get from valueChange in the table
resource = generarSource(paciente); <-generarSoruce declare bottom
bwo = new BrowserWindowOpener(resource);
bwo .extend(btnVerReporte); <-btn shows pdf
}
[code]
//generarSource method
private StreamResource generarSource(final VistaAdmEstudiosPorRealizar paciente) {
return new StreamResource(new StreamResource.StreamSource() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
Conexion conexion = null;
String reportFile = "";
byte b = null;
log.trace("IdRutina del paciente seleccionado: " + paciente.getIdRutina());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("filter",paciente.getIdRutina());
parameters.put("parametro1", paciente.getTipoExamen());
parameters.put("parametro2", paciente.getRazonSocial());
parameters.put("parametro3", paciente.getApellidoPaciente()+", "+paciente.getNombrePaciente());
parameters.put("parametro4", paciente.getDireccion());
parameters.put("parametro5", paciente.getNumeroDeDocumento());
parameters.put("parametro6", paciente.getFechaNacimiento());
parameters.put("parametro7", paciente.getNombreArt());
parameters.put("parametro8", paciente.getEstadoCivil());
parameters.put("parametro9", paciente.getTelefono());
parameters.put("parametro10",paciente.getTipoDeDocumento());
parameters.put("parametro11",paciente.getNacionalidad());
parameters.put("parametro12",paciente.getFechaIngreso());
parameters.put("parametro13",paciente.getOrientacionRutina());
try {
if(paciente.getTipoExamen().equalsIgnoreCase("periodico")){
reportFile = "com/report/rutinasAVisarPeriodico.jasper";
}else{
reportFile = "com/report/rutinasAVisarIEO.jasper";
}
InputStream report = getClass().getClassLoader().getResourceAsStream(reportFile);
if (report == null) {
Notification.show("No report!", Type.ERROR_MESSAGE);
return null;
}
conexion = new Conexion();
b = JasperRunManager.runReportToPdf(report, parameters, conexion.getConexion());
// conexion.getConexion().commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new ByteArrayInputStream(b);
}
}, "reporte"+paciente.getTipoExamen()+".pdf");
}
[/code]try with setTimeCache and all kind of ways but no luck.
Also attach some view of the behaviors.
any help appreciated!
Regards
: