1 16 17 package org.springframework.web.servlet.view.jasperreports; 18 19 import net.sf.jasperreports.engine.JRExporter; 20 21 import org.springframework.beans.BeanUtils; 22 23 34 public class ConfigurableJasperReportsView extends AbstractJasperReportsSingleFormatView { 35 36 private Class exporterClass; 37 38 private boolean useWriter = true; 39 40 41 46 public void setExporterClass(Class exporterClass) { 47 if (!(JRExporter.class.isAssignableFrom(exporterClass))) { 48 throw new IllegalArgumentException ( 49 "Exporter class [" + exporterClass.getName() + "] does not implement JRExporter"); 50 } 51 this.exporterClass = exporterClass; 52 } 53 54 59 public void setUseWriter(boolean useWriter) { 60 this.useWriter = useWriter; 61 } 62 63 66 protected void onInit() { 67 if (this.exporterClass == null) { 68 throw new IllegalArgumentException ("exporterClass is required"); 69 } 70 } 71 72 73 78 protected JRExporter createExporter() { 79 return (JRExporter) BeanUtils.instantiateClass(this.exporterClass); 80 } 81 82 86 protected boolean useWriter() { 87 return this.useWriter; 88 } 89 90 } 91 | Popular Tags |