У меня возникла эта проблема, когда я пытаюсь экспортировать данные в PDF, метод делает все, но он не загружает PDF или даже не генерирует. версияЭкспорт PDF на JSF не экспортируется
Netbeans: 8,2
JSF: 2.2
Primefaces: 5,3
Libraries used:
Jasperreports 6.3
poi 3.14
commons-beanutils-1.9.0
commons-collection-3.2.2
commons-digester-2.1
commons-logging-1.1.1
groovy-all-2.4.0
itext-2.1.7.js5
jaxp-ri
jcommon-1.0.23
jfreechart-1.0.19
И мой метод:
public void exportpdf(OrdenRetiro or) throws JRException, IOException {
conexion con = new conexion();
Map<String, Object> parametros = new HashMap<String, Object>();
FacesContext context = FacesContext.getCurrentInstance();
ServletContext servleContext = (ServletContext) context.getExternalContext().getContext();
parametros.put("RutaImagen", servleContext.getRealPath("/reportes/"));
parametros.put("cod_ordenretiro", or.getCod_ordenretiro());
String temperatura = or.getEs_temperado()==1?"ReporteFreezer.jasper":"ReporteNoFreezer.jasper";
String dirReporte = servleContext.getRealPath("/reportes/"+temperatura);
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
response.addHeader("Content-disposition", "attachment;filename=Orden de Retiro"+or.getCod_ordenretiro()+".pdf");
response.setContentType("application/pdf");
JasperPrint impres = JasperFillManager.fillReport(dirReporte, parametros, con.getConnection());
JasperExportManager.exportReportToPdfStream(impres, response.getOutputStream());
context.responseComplete();
}
Любая идея?
Вы пытались создать отчет с помощью простого тест (экспорт в файл)? –
У меня уже есть другой проект, который имеет ту же структуру и экспорт работает, вы имеете в виду загрузить файл в папку напрямую? – Jorge
Вы можете создать простое консольное приложение, чтобы проверить часть кода, относящуюся к отчету об экспорте, в формате pdf (с API JasperReports). –