|
Anyframe Web | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
org.springframework.web.servlet.view.AbstractUrlBasedView
anyframe.web.springmvc.jasperreports.ExtendedAbstractJasperReportsView
anyframe.web.springmvc.jasperreports.ExtendedJasperReportsMultiFormatView
public class ExtendedJasperReportsMultiFormatView
Jasper Reports view class that allows for the actual rendering format to be specified at runtime using a parameter contained in the model.
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 Controller to
Spring through as part of the model and the mapping key is used to map a
logical format to an actual JasperReports view class. For example you might
add the following code to your Controller:
Map model = new HashMap();
model.put("format", "pdf");
Here format is the format key and pdf is the
mapping key. When rendering a report, this class looks for a model parameter
under the format key, which by default is format. It then
uses the value of this parameter to lookup the actual View
class to use. The default mappings for this lookup are:
csv - JasperReportsCsvViewhtml - JasperReportsHtmlViewpdf - JasperReportsPdfViewxls - JasperReportsXlsView
The format key can be changed using the formatKey property and
the mapping key to view class mappings can be changed using the
formatMappings property.
We changed org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView Class into anyframe.web.springmvc.common.jasperreports.ExtendedAbstractJasperReportsMultiFormatView Class in Anyframe.
setFormatKey(java.lang.String)| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_FORMAT_KEY
Default value used for format key: "format" |
| Fields inherited from class anyframe.web.springmvc.jasperreports.ExtendedAbstractJasperReportsView |
|---|
CONTENT_DISPOSITION_INLINE, HEADER_CONTENT_DISPOSITION |
| Fields inherited from class org.springframework.web.servlet.view.AbstractView |
|---|
DEFAULT_CONTENT_TYPE |
| Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
ExtendedJasperReportsMultiFormatView()
Creates a new JasperReportsMultiFormatView instance with a
default set of mappings. |
|
| Method Summary | |
|---|---|
java.util.Properties |
getContentDispositionMappings()
Return the mappings of Content-Disposition header values
to mapping keys. |
protected void |
renderReport(net.sf.jasperreports.engine.JasperPrint populatedReport,
java.util.Map 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.Properties mappingsWithClassNames)
Set the mappings of format discriminators to view class names. |
| Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView |
|---|
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString |
| Methods inherited from class org.springframework.web.servlet.view.AbstractView |
|---|
addStaticAttribute, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute, writeToResponse |
| Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
|---|
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext |
| Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
|---|
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_FORMAT_KEY
| Constructor Detail |
|---|
public ExtendedJasperReportsMultiFormatView()
JasperReportsMultiFormatView instance with a
default set of mappings.
| Method Detail |
|---|
public void setFormatKey(java.lang.String formatKey)
public void setFormatMappings(java.util.Properties mappingsWithClassNames)
csv - JasperReportsCsvViewhtml - JasperReportsHtmlViewpdf - JasperReportsPdfViewxls - JasperReportsXlsView
public void setContentDispositionMappings(java.util.Properties mappings)
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.
public java.util.Properties getContentDispositionMappings()
Content-Disposition header values
to mapping keys. Mainly available for configuration through property
paths that specify individual keys.
protected void renderReport(net.sf.jasperreports.engine.JasperPrint populatedReport,
java.util.Map model,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
renderReport in class ExtendedAbstractJasperReportsViewpopulatedReport - the populated JasperPrint to rendermodel - the map containing report parametersresponse - the HTTP response the report should be rendered to
java.lang.Exception - if rendering failedAbstractView.getContentType(),
ServletResponse.setContentType(java.lang.String),
ServletResponse.setCharacterEncoding(java.lang.String)
|
Anyframe Web | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||