fixed JasperReports exporter parameter initialization for multi-format views

This commit is contained in:
Juergen Hoeller 2009-04-15 23:18:57 +00:00
parent 310a3a2d71
commit d27cbee69c
5 changed files with 326 additions and 297 deletions

View File

@ -255,6 +255,13 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
return this.exporterParameters;
}
/**
* Allows subclasses to populate the converted exporter parameters.
*/
protected void setConvertedExporterParameters(Map<JRExporterParameter, Object> convertedExporterParameters) {
this.convertedExporterParameters = convertedExporterParameters;
}
/**
* Allows subclasses to retrieve the converted exporter parameters.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -183,13 +183,10 @@ public class JasperReportsMultiFormatView extends AbstractJasperReportsView {
}
AbstractJasperReportsView view = (AbstractJasperReportsView) BeanUtils.instantiateClass(viewClass);
// Copy appropriate properties across.
view.setExporterParameters(getExporterParameters());
// Can skip most initialization since all relevant URL processing
// has been done - just need to convert parameters on the sub view.
view.convertExporterParameters();
view.setExporterParameters(getExporterParameters());
view.setConvertedExporterParameters(getConvertedExporterParameters());
// Prepare response and render report.
populateContentDispositionIfNecessary(response, format);

View File

@ -29,6 +29,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.ui.jasperreports.PersonBean;
import org.springframework.ui.jasperreports.ProductBean;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
@ -44,17 +45,8 @@ public abstract class AbstractJasperReportsTests extends TestCase {
protected static final String SUB_REPORT_PARENT = "/org/springframework/ui/jasperreports/subReportParent.jrxml";
protected static boolean canCompileReport;
static {
try {
Class.forName("org.eclipse.jdt.internal.compiler.Compiler");
canCompileReport = true;
}
catch (ClassNotFoundException ex) {
canCompileReport = false;
}
}
protected static final boolean canCompileReport = ClassUtils.isPresent(
"org.eclipse.jdt.internal.compiler.Compiler", AbstractJasperReportsTests.class.getClassLoader());
protected MockHttpServletRequest request;

View File

@ -69,7 +69,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
if (view instanceof AbstractJasperReportsSingleFormatView &&
((AbstractJasperReportsSingleFormatView) view).useWriter()) {
String output = response.getContentAsString();
assertTrue("Output should contain 'MeineSeite'", output.indexOf("MeineSeite") > -1);
assertTrue("Output should contain 'MeineSeite'", output.contains("MeineSeite"));
}
}

View File

@ -16,6 +16,7 @@
<orderEntry type="module" module-name="context" />
<orderEntry type="module" module-name="context-support" />
<orderEntry type="module" module-name="core" />
<orderEntry type="module" module-name="oxm" />
<orderEntry type="module" module-name="web" />
<orderEntry type="module-library">
<library>
@ -268,7 +269,39 @@
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module" module-name="oxm" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.beanutils/1.7.0/com.springsource.org.apache.commons.beanutils-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.beanutils/1.7.0/com.springsource.org.apache.commons.beanutils-sources-1.7.0.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.digester/1.8.0/com.springsource.org.apache.commons.digester-1.8.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.digester/1.8.0/com.springsource.org.apache.commons.digester-sources-1.8.0.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$IVY_CACHE$/org.eclipse.jdt/com.springsource.org.eclipse.jdt.core.compiler.batch/3.3.0/com.springsource.org.eclipse.jdt.core.compiler.batch-3.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$IVY_CACHE$/org.eclipse.jdt/com.springsource.org.eclipse.jdt.core.compiler.batch/3.3.0/com.springsource.org.eclipse.jdt.core.compiler.batch-sources-3.3.0.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
<component name="copyright">
<Base>