JasperReport中不推荐使用的方法

问题描述 投票:0回答:2

我正在使用jasperreports-6.1.0.jar,并且在JRPrintServiceExporterParameter类中有一些不推荐使用的方法。

我如何找出我应该使用的方法或类?

如何确定使用弃用方法是否安全?

编辑:

这是我的代码中不赞成使用的部分:

exporter = new JRPrintServiceExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, printService[selectedService]);
        exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printService[selectedService].getAttributes());
        exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
        exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
        exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);
        exporter.exportReport();
java jasper-reports deprecated
2个回答
0
投票

不推荐使用的方法可以安全使用。他们继续工作,但将来可能会被删除。所以现在你很好。

但是你应该考虑清理代码,方法是阅读Javadocs here并查看有关调用所需功能的新方法的建议。


0
投票

期待this

在我的案例中我的解决方案

PrinterName printerName = new PrinterName(selectedService.getName(), null);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
                parametros, beanCollectionDataSource);

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
        printServiceAttributeSet.add(printerName);

JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
configuration.setDisplayPageDialog(false);
configuration.setDisplayPrintDialog(false);
exporter.setConfiguration(configuration);
exporter.exportReport();
© www.soinside.com 2019 - 2024. All rights reserved.