1

I am using a jasperreports-6.1.0.jar, and there are some deprecated methods in class JRPrintServiceExporterParameter.

How do I find out what method or class am I supposed to use?

How do I find out if it's safe to just use deprecated methods?

EDIT:

this is the deprecated part of my code:

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();
PRO_gramista
  • 922
  • 1
  • 9
  • 26

2 Answers2

1

look at this

My solution in my case

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();
0

Deprecated methods are safe to use. They continue to work but may be removed in the future. So for now you are fine.

But you should consider cleaning up your code by reading the Javadocs here and looking at the recommendation for the new way to call the features you need.

Ari Maniatis
  • 8,038
  • 3
  • 19
  • 28