|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -27,26 +27,26 @@ import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Jasper Reports view class that allows for the actual rendering format to be |
|
|
|
* Jasper Reports view class that allows for the actual rendering format |
|
|
|
* specified at runtime using a parameter contained in the model. |
|
|
|
* to be specified at runtime using a parameter contained in the model. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>This view works on the concept of a format key and a mapping key. |
|
|
|
* <p>This view works on the concept of a format key and a mapping key. |
|
|
|
* The format key is used to pass the mapping key from your |
|
|
|
* The format key is used to pass the mapping key from your {@code Controller} |
|
|
|
* {@code Controller} to Spring through as part of the model and the |
|
|
|
* to Spring through as part of the model and the mapping key is used to map |
|
|
|
* mapping key is used to map a logical format to an actual JasperReports |
|
|
|
* a logical format to an actual JasperReports view class. |
|
|
|
* view class. For example you might add the following code to your |
|
|
|
* |
|
|
|
* {@code Controller}: |
|
|
|
* <p>For example, you might add the following code to your {@code Controller}: |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
* Map<String, Object> model = new HashMap<String, Object>(); |
|
|
|
* Map<String, Object> model = new HashMap<String, Object>(); |
|
|
|
* model.put("format", "pdf");</pre> |
|
|
|
* model.put("format", "pdf");</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* Here {@code format} is the format key and {@code pdf} is |
|
|
|
* Here {@code format} is the format key and {@code pdf} is the mapping key. |
|
|
|
* the mapping key. When rendering a report, this class looks for a |
|
|
|
* When rendering a report, this class looks for a model parameter under the |
|
|
|
* model parameter under the format key, which by default is |
|
|
|
* format key, which by default is {@code format}. It then uses the value of |
|
|
|
* {@code format}. It then uses the value of this parameter to lookup |
|
|
|
* this parameter to lookup the actual {@code View} class to use. |
|
|
|
* the actual {@code View} class to use. The default mappings for this |
|
|
|
* |
|
|
|
* lookup are: |
|
|
|
* <p>The default mappings for the format lookup are: |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><ul> |
|
|
|
* <p><ul> |
|
|
|
* <li>{@code csv} - {@code JasperReportsCsvView}</li> |
|
|
|
* <li>{@code csv} - {@code JasperReportsCsvView}</li> |
|
|
|
@ -55,8 +55,8 @@ import org.springframework.util.CollectionUtils; |
|
|
|
* <li>{@code xls} - {@code JasperReportsXlsView}</li> |
|
|
|
* <li>{@code xls} - {@code JasperReportsXlsView}</li> |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>The format key can be changed using the {@code formatKey} |
|
|
|
* <p>The format key can be changed using the {@code formatKey} property. |
|
|
|
* property and the mapping key to view class mappings can be changed using the |
|
|
|
* The applicable key-to-view-class mappings can be configured using the |
|
|
|
* {@code formatMappings} property. |
|
|
|
* {@code formatMappings} property. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rob Harrop |
|
|
|
* @author Rob Harrop |
|
|
|
@ -102,6 +102,7 @@ public class JasperReportsMultiFormatView extends AbstractJasperReportsView { |
|
|
|
this.formatMappings.put("xls", JasperReportsXlsView.class); |
|
|
|
this.formatMappings.put("xls", JasperReportsXlsView.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the key of the model parameter that holds the format discriminator. |
|
|
|
* Set the key of the model parameter that holds the format discriminator. |
|
|
|
* Default is "format". |
|
|
|
* Default is "format". |
|
|
|
|