static
Method Summary |
protected boolean |
generatesDownloadContent()
Return whether this view generates download content
(typically binary content like PDF or Excel files). |
java.util.Properties |
getContentDispositionMappings()
Return the mappings of Content-Disposition header values to
mapping keys. |
private void |
populateContentDispositionIfNecessary(javax.servlet.http.HttpServletResponse response,
java.lang.String format)
Adds/overwrites the Content-Disposition header value with the format-specific
value if the mappings have been specified and a valid one exists for the given format. |
protected void |
renderReport(net.sf.jasperreports.engine.JasperPrint populatedReport,
java.util.Map<java.lang.String,java.lang.Object> model,
javax.servlet.http.HttpServletResponse response)
Locates the format key in the model using the configured discriminator key and uses this
key to lookup the appropriate view class from the mappings. |
void |
setContentDispositionMappings(java.util.Properties mappings)
Set the mappings of Content-Disposition header values to
mapping keys. |
void |
setFormatKey(java.lang.String formatKey)
Set the key of the model parameter that holds the format discriminator. |
void |
setFormatMappings(java.util.Map<java.lang.String,java.lang.Class<? extends AbstractJasperReportsView>> formatMappings)
Set the mappings of format discriminators to view class names. |
Methods inherited from class org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView |
convertExporterParameters, convertParameterValue, convertReportData, convertToExporterParameter, createReport, exposeLocalizationContext, fillReport, getConvertedExporterParameters, getExporterParameter, getExporterParameters, getJdbcDataSource, getReport, getReportData, getReportDataTypes, initApplicationContext, isUrlRequired, loadReport, loadReport, onInit, postProcessReport, renderMergedOutputModel, setConvertedExporterParameters, setExporterParameters, setHeaders, setJdbcDataSource, setReportDataKey, setSubReportDataKeys, setSubReportUrls |
Methods inherited from class org.springframework.web.servlet.view.AbstractView |
addStaticAttribute, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute, writeToResponse |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_FORMAT_KEY
public static final java.lang.String DEFAULT_FORMAT_KEY
- Default value used for format key: "format"
- See Also:
- Constant Field Values
formatKey
private java.lang.String formatKey
- The key of the model parameter that holds the format key.
formatMappings
private java.util.Map<java.lang.String,java.lang.Class<? extends AbstractJasperReportsView>> formatMappings
- Stores the format mappings, with the format discriminator
as key and the corresponding view class as value.
contentDispositionMappings
private java.util.Properties contentDispositionMappings
- Stores the mappings of mapping keys to Content-Disposition header values.
JasperReportsMultiFormatView
public JasperReportsMultiFormatView()
- Creates a new
JasperReportsMultiFormatView instance
with a default set of mappings.
setFormatKey
public void setFormatKey(java.lang.String formatKey)
- Set the key of the model parameter that holds the format discriminator.
Default is "format".
setFormatMappings
public void setFormatMappings(java.util.Map<java.lang.String,java.lang.Class<? extends AbstractJasperReportsView>> formatMappings)
- Set the mappings of format discriminators to view class names.
The default mappings are:
csv - JasperReportsCsvView
html - JasperReportsHtmlView
pdf - JasperReportsPdfView
xls - JasperReportsXlsView
setContentDispositionMappings
public void setContentDispositionMappings(java.util.Properties mappings)
- Set the mappings of
Content-Disposition header values to
mapping keys. If specified, Spring will look at these mappings to determine
the value of the Content-Disposition header for a given
format mapping.
getContentDispositionMappings
public java.util.Properties getContentDispositionMappings()
- Return the mappings of
Content-Disposition header values to
mapping keys. Mainly available for configuration through property paths
that specify individual keys.
generatesDownloadContent
protected boolean generatesDownloadContent()
- Description copied from class:
AbstractView
- Return whether this view generates download content
(typically binary content like PDF or Excel files).
The default implementation returns false . Subclasses are
encouraged to return true here if they know that they are
generating download content that requires temporary caching on the
client side, typically via the response OutputStream.
- Overrides:
generatesDownloadContent in class AbstractView
- See Also:
AbstractView.prepareResponse(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) ,
ServletResponse.getOutputStream()
renderReport
protected void renderReport(net.sf.jasperreports.engine.JasperPrint populatedReport,
java.util.Map<java.lang.String,java.lang.Object> model,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
- Locates the format key in the model using the configured discriminator key and uses this
key to lookup the appropriate view class from the mappings. The rendering of the
report is then delegated to an instance of that view class.
- Specified by:
renderReport in class AbstractJasperReportsView
- Parameters:
populatedReport - the populated JasperPrint to rendermodel - the map containing report parametersresponse - the HTTP response the report should be rendered to
- Throws:
java.lang.Exception - if rendering failed- See Also:
AbstractView.getContentType() ,
ServletResponse.setContentType(java.lang.String) ,
ServletResponse.setCharacterEncoding(java.lang.String)
populateContentDispositionIfNecessary
private void populateContentDispositionIfNecessary(javax.servlet.http.HttpServletResponse response,
java.lang.String format)
- Adds/overwrites the
Content-Disposition header value with the format-specific
value if the mappings have been specified and a valid one exists for the given format.
- Parameters:
response - the HttpServletResponse to set the header informat - the format key of the mapping- See Also:
setContentDispositionMappings(java.util.Properties)
|