Java Doc for AbstractJasperReportsView.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » view » jasperreports » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.servlet.view.jasperreports 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.view.AbstractUrlBasedView
   org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView

All known Subclasses:   org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView,  org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsSingleFormatView,
AbstractJasperReportsView
abstract public class AbstractJasperReportsView extends AbstractUrlBasedView (Code)
Base class for all JasperReports views. Applies on-the-fly compilation of report designs as required and coordinates the rendering process. The resource path of the main report needs to be specified as url.

This class is responsible for getting report data from the model that has been provided to the view. The default implementation checks for a model object under the specified reportDataKey first, then falls back to looking for a value of type JRDataSource, java.util.Collection, object array (in that order).

If no JRDataSource can be found in the model, then reports will be filled using the configured javax.sql.DataSource if any. If neither a JRDataSource or javax.sql.DataSource is available then an IllegalArgumentException is raised.

Provides support for sub-reports through the subReportUrls and subReportDataKeys properties.

When using sub-reports, the master report should be configured using the url property and the sub-reports files should be configured using the subReportUrls property. Each entry in the subReportUrls Map corresponds to an individual sub-report. The key of an entry must match up to a sub-report parameter in your report file of type net.sf.jasperreports.engine.JasperReport, and the value of an entry must be the URL for the sub-report file.

For sub-reports that require an instance of JRDataSource, that is, they don't have a hard-coded query for data retrieval, you can include the appropriate data in your model as would with the data source for the parent report. However, you must provide a List of parameter names that need to be converted to JRDataSource instances for the sub-report via the subReportDataKeys property. When using JRDataSource instances for sub-reports, you must specify a value for the reportDataKey property, indicating the data to use for the main report.

Allows for exporter parameters to be configured declatively using the exporterParameters property. This is a Map typed property where the key of an entry corresponds to the fully-qualified name of the static field for the JRExporterParameter and the value of an entry is the value you want to assign to the exporter parameter.

Response headers can be controlled via the headers property. Spring will attempt to set the correct value for the Content-Diposition header so that reports render correctly in Internet Explorer. However, you can override this setting through the headers property.
author:
   Rob Harrop
author:
   Juergen Hoeller
since:
   1.1.3
See Also:   AbstractJasperReportsView.setUrl
See Also:   AbstractJasperReportsView.setReportDataKey
See Also:   AbstractJasperReportsView.setSubReportUrls
See Also:   AbstractJasperReportsView.setSubReportDataKeys
See Also:   AbstractJasperReportsView.setHeaders
See Also:   AbstractJasperReportsView.setExporterParameters
See Also:   AbstractJasperReportsView.setJdbcDataSource



Field Summary
final protected static  StringCONTENT_DISPOSITION_INLINE
     The default Content-Disposition header.
final protected static  StringHEADER_CONTENT_DISPOSITION
     Constant that defines "Content-Disposition" header.


Method Summary
final protected  voidconvertExporterParameters()
     Converts the exporter parameters passed in by the user which may be keyed by Strings corresponding to the fully qualified name of the JRExporterParameter into parameters which are keyed by JRExporterParameter.
protected  ObjectconvertParameterValue(JRExporterParameter parameter, Object value)
     Convert the supplied parameter value into the actual type required by the corresponding JRExporterParameter .
protected  JRDataSourceconvertReportData(Object value)
     Convert the given report data value to a JRDataSource.
protected  JRExporterParameterconvertToExporterParameter(String fqFieldName)
     Convert the given fully qualified field name to a corresponding JRExporterParameter instance.
Parameters:
  fqFieldName - the fully qualified field name, consistingof the class name followed by a dot followed by the field name(e.g.
protected  voidexposeLocalizationContext(Map model, HttpServletRequest request)
     Expose current Spring-managed Locale and MessageSource to JasperReports i18n ($R expressions etc).
protected  JasperPrintfillReport(Map model)
     Create a populated JasperPrint instance from the configured JasperReport instance.

By default, thois method will use any JRDataSource instance (or wrappable Object) that can be located using AbstractJasperReportsView.getReportData . If no JRDataSource can be found, this method will use a JDBC Connection obtained from the configured javax.sql.DataSource (or a DataSource attribute in the model).

protected  MapgetConvertedExporterParameters()
     Allows subclasses to retrieve the converted exporter parameters.
protected  JRExporterParametergetExporterParameter(Object parameter)
     Return a JRExporterParameter for the given parameter object, converting it from a String if necessary.
public  MapgetExporterParameters()
     Return the exporter parameters that this view uses, if any.
protected  DataSourcegetJdbcDataSource()
     Return the javax.sql.DataSource that this view uses, if any.
protected  JasperReportgetReport()
     Allows sub-classes to get access to the JasperReport instance loaded by Spring.
protected  JRCompilergetReportCompiler()
     Return the JRCompiler instance to use for compiling ".jrxml" report files.
protected  JRDataSourcegetReportData(Map model)
     Find an instance of JRDataSource in the given model map or create an appropriate JRDataSource for passed-in report data.
protected  Class[]getReportDataTypes()
     Return the value types that can be converted to a JRDataSource, in prioritized order.
final protected  voidinitApplicationContext()
     Checks to see that a valid report file URL is supplied in the configuration.
protected  voidonInit()
     Subclasses can override this to add some custom initialization logic.
protected  voidpostProcessReport(JasperPrint populatedReport, Map model)
     Template method to be overridden for custom post-processing of the populated report.
protected  voidrenderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
     Finds the report data to use for rendering the report and then invokes the renderReport method that should be implemented by the subclass.
Parameters:
  model - the model map, as passed in for view rendering.
abstract protected  voidrenderReport(JasperPrint populatedReport, Map model, HttpServletResponse response)
     Subclasses should implement this method to perform the actual rendering process.

Note that the content type has not been set yet: Implementors should build a content type String and set it via response.setContentType. If necessary, this can include a charset clause for a specific encoding. The latter will only be necessary for textual output onto a Writer, and only in case of the encoding being specified in the JasperReports exporter parameters.

WARNING: Implementors should not use response.setCharacterEncoding unless they are willing to depend on Servlet API 2.4 or higher.

public  voidsetExporterParameters(Map parameters)
     Set the exporter parameters that should be used when rendering a view.
Parameters:
  parameters - Map with the fully qualified field nameof the JRExporterParameter instance as key(e.g.
public  voidsetHeaders(Properties headers)
     Specify the set of headers that are included in each of response.
public  voidsetJdbcDataSource(DataSource jdbcDataSource)
     Specify the javax.sql.DataSource to use for reports with embedded SQL statements.
public  voidsetReportCompiler(JRCompiler reportCompiler)
     Specify the JRCompiler implementation to use for compiling a ".jrxml" report file on-the-fly into a report class.
public  voidsetReportDataKey(String reportDataKey)
     Set the name of the model attribute that represents the report data. If not specified, the model map will be searched for a matching value type.

A JRDataSource will be taken as-is.

public  voidsetSubReportDataKeys(String[] subReportDataKeys)
     Set the list of names corresponding to the model parameters that will contain data source objects for use in sub-reports.
public  voidsetSubReportUrls(Properties subReports)
     Specify resource paths which must be loaded as instances of JasperReport and passed to the JasperReports engine for rendering as sub-reports, under the same keys as in this mapping.

Field Detail
CONTENT_DISPOSITION_INLINE
final protected static String CONTENT_DISPOSITION_INLINE(Code)
The default Content-Disposition header. Used to make IE play nice.



HEADER_CONTENT_DISPOSITION
final protected static String HEADER_CONTENT_DISPOSITION(Code)
Constant that defines "Content-Disposition" header.





Method Detail
convertExporterParameters
final protected void convertExporterParameters()(Code)
Converts the exporter parameters passed in by the user which may be keyed by Strings corresponding to the fully qualified name of the JRExporterParameter into parameters which are keyed by JRExporterParameter.
See Also:   AbstractJasperReportsView.getExporterParameter(Object)



convertParameterValue
protected Object convertParameterValue(JRExporterParameter parameter, Object value)(Code)
Convert the supplied parameter value into the actual type required by the corresponding JRExporterParameter .

The default implementation simply converts the String values "true" and "false" into corresponding Boolean objects, and tries to convert String values that start with a digit into Integer objects (simply keeping them as String if number conversion fails).




convertReportData
protected JRDataSource convertReportData(Object value) throws IllegalArgumentException(Code)
Convert the given report data value to a JRDataSource.

The default implementation delegates to JasperReportUtils unless the report data value is an instance of JRDataSourceProvider. A JRDataSource, JRDataSourceProvider, java.util.Collection or object array is detected. JRDataSources are returned as is, whilst JRDataSourceProviders are used to create an instance of JRDataSource which is then returned. The latter two are converted to JRBeanCollectionDataSource or JRBeanArrayDataSource, respectively.
Parameters:
  value - the report data value to convert the JRDataSource
throws:
  IllegalArgumentException - if the value could not be converted
See Also:   org.springframework.ui.jasperreports.JasperReportsUtils.convertReportData
See Also:   net.sf.jasperreports.engine.JRDataSource
See Also:   net.sf.jasperreports.engine.JRDataSourceProvider
See Also:   net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
See Also:   net.sf.jasperreports.engine.data.JRBeanArrayDataSource




convertToExporterParameter
protected JRExporterParameter convertToExporterParameter(String fqFieldName)(Code)
Convert the given fully qualified field name to a corresponding JRExporterParameter instance.
Parameters:
  fqFieldName - the fully qualified field name, consistingof the class name followed by a dot followed by the field name(e.g. "net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI") the corresponding JRExporterParameter instance



exposeLocalizationContext
protected void exposeLocalizationContext(Map model, HttpServletRequest request)(Code)
Expose current Spring-managed Locale and MessageSource to JasperReports i18n ($R expressions etc). The MessageSource should only be exposed as JasperReports resource bundle if no such bundle is defined in the report itself.

Default implementation exposes the Spring RequestContext Locale and a MessageSourceResourceBundle adapter for the Spring ApplicationContext, analogous to the JstlUtils.exposeLocalizationContext method.
See Also:   org.springframework.web.servlet.support.RequestContextUtils.getLocale
See Also:   org.springframework.context.support.MessageSourceResourceBundle
See Also:   AbstractJasperReportsView.getApplicationContext()
See Also:   net.sf.jasperreports.engine.JRParameter.REPORT_LOCALE
See Also:   net.sf.jasperreports.engine.JRParameter.REPORT_RESOURCE_BUNDLE
See Also:   org.springframework.web.servlet.support.JstlUtils.exposeLocalizationContext




fillReport
protected JasperPrint fillReport(Map model) throws IllegalArgumentException, SQLException, JRException(Code)
Create a populated JasperPrint instance from the configured JasperReport instance.

By default, thois method will use any JRDataSource instance (or wrappable Object) that can be located using AbstractJasperReportsView.getReportData . If no JRDataSource can be found, this method will use a JDBC Connection obtained from the configured javax.sql.DataSource (or a DataSource attribute in the model). If no JDBC DataSource can be found either, the JasperReports engine will be invoked with plain model Map, assuming that the model contains parameters that identify the source for report data (e.g. Hibernate or JPA queries).
Parameters:
  model - the model for this request
throws:
  IllegalArgumentException - if no JRDataSource can be foundand no javax.sql.DataSource is supplied
throws:
  SQLException - if there is an error when populating the report usingthe javax.sql.DataSource
throws:
  JRException - if there is an error when populating the report usinga JRDataSource the populated JasperPrint instance
See Also:   AbstractJasperReportsView.getReportData
See Also:   AbstractJasperReportsView.setJdbcDataSource




getConvertedExporterParameters
protected Map getConvertedExporterParameters()(Code)
Allows subclasses to retrieve the converted exporter parameters.



getExporterParameter
protected JRExporterParameter getExporterParameter(Object parameter)(Code)
Return a JRExporterParameter for the given parameter object, converting it from a String if necessary.
Parameters:
  parameter - the parameter object, either a String or a JRExporterParameter a JRExporterParameter for the given parameter object
See Also:   AbstractJasperReportsView.convertToExporterParameter(String)



getExporterParameters
public Map getExporterParameters()(Code)
Return the exporter parameters that this view uses, if any.



getJdbcDataSource
protected DataSource getJdbcDataSource()(Code)
Return the javax.sql.DataSource that this view uses, if any.



getReport
protected JasperReport getReport()(Code)
Allows sub-classes to get access to the JasperReport instance loaded by Spring. an instance of JasperReport



getReportCompiler
protected JRCompiler getReportCompiler()(Code)
Return the JRCompiler instance to use for compiling ".jrxml" report files.



getReportData
protected JRDataSource getReportData(Map model)(Code)
Find an instance of JRDataSource in the given model map or create an appropriate JRDataSource for passed-in report data.

The default implementation checks for a model object under the specified "reportDataKey" first, then falls back to looking for a value of type JRDataSource, java.util.Collection, object array (in that order).
Parameters:
  model - the model map, as passed in for view rendering the JRDataSource or null if the data source is not found
See Also:   AbstractJasperReportsView.setReportDataKey
See Also:   AbstractJasperReportsView.convertReportData
See Also:   AbstractJasperReportsView.getReportDataTypes




getReportDataTypes
protected Class[] getReportDataTypes()(Code)
Return the value types that can be converted to a JRDataSource, in prioritized order. Should only return types that the AbstractJasperReportsView.convertReportData method is actually able to convert.

Default value types are: JRDataSource, JRDataSourceProvider java.util.Collection and Object array. the value types in prioritized order




initApplicationContext
final protected void initApplicationContext() throws ApplicationContextException(Code)
Checks to see that a valid report file URL is supplied in the configuration. Compiles the report file is necessary.

Subclasses can add custom initialization logic by overriding the AbstractJasperReportsView.onInit method.
See Also:   AbstractJasperReportsView.onInit()
See Also:   




onInit
protected void onInit()(Code)
Subclasses can override this to add some custom initialization logic. Called by AbstractJasperReportsView.initApplicationContext() as soon as all standard initialization logic has finished executing.
See Also:   AbstractJasperReportsView.initApplicationContext()



postProcessReport
protected void postProcessReport(JasperPrint populatedReport, Map model) throws Exception(Code)
Template method to be overridden for custom post-processing of the populated report. Invoked after filling but before rendering.

The default implementation is empty.
Parameters:
  populatedReport - the populated JasperPrint
Parameters:
  model - the map containing report parameters
throws:
  Exception - if post-processing failed




renderMergedOutputModel
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Finds the report data to use for rendering the report and then invokes the renderReport method that should be implemented by the subclass.
Parameters:
  model - the model map, as passed in for view rendering. Must containa report data value that can be converted to a JRDataSource,acccording to the getReportData method.
See Also:   AbstractJasperReportsView.getReportData



renderReport
abstract protected void renderReport(JasperPrint populatedReport, Map model, HttpServletResponse response) throws Exception(Code)
Subclasses should implement this method to perform the actual rendering process.

Note that the content type has not been set yet: Implementors should build a content type String and set it via response.setContentType. If necessary, this can include a charset clause for a specific encoding. The latter will only be necessary for textual output onto a Writer, and only in case of the encoding being specified in the JasperReports exporter parameters.

WARNING: Implementors should not use response.setCharacterEncoding unless they are willing to depend on Servlet API 2.4 or higher. Prefer a concatenated content type String with a charset clause instead.
Parameters:
  populatedReport - the populated JasperPrint to render
Parameters:
  model - the map containing report parameters
Parameters:
  response - the HTTP response the report should be rendered to
throws:
  Exception - if rendering failed
See Also:   AbstractJasperReportsView.getContentType()
See Also:   javax.servlet.ServletResponse.setContentType
See Also:   javax.servlet.ServletResponse.setCharacterEncoding




setExporterParameters
public void setExporterParameters(Map parameters)(Code)
Set the exporter parameters that should be used when rendering a view.
Parameters:
  parameters - Map with the fully qualified field nameof the JRExporterParameter instance as key(e.g. "net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI")and the value you wish to assign to the parameter as value



setHeaders
public void setHeaders(Properties headers)(Code)
Specify the set of headers that are included in each of response.
Parameters:
  headers - the headers to write to each response.



setJdbcDataSource
public void setJdbcDataSource(DataSource jdbcDataSource)(Code)
Specify the javax.sql.DataSource to use for reports with embedded SQL statements.



setReportCompiler
public void setReportCompiler(JRCompiler reportCompiler)(Code)
Specify the JRCompiler implementation to use for compiling a ".jrxml" report file on-the-fly into a report class.

By default, a JRDefaultCompiler will be used, delegating to the Eclipse JDT compiler or the Sun JDK compiler underneath.
See Also:   net.sf.jasperreports.engine.design.JRDefaultCompiler




setReportDataKey
public void setReportDataKey(String reportDataKey)(Code)
Set the name of the model attribute that represents the report data. If not specified, the model map will be searched for a matching value type.

A JRDataSource will be taken as-is. For other types, conversion will apply: By default, a java.util.Collection will be converted to JRBeanCollectionDataSource, and an object array to JRBeanArrayDataSource.

Note: If you pass in a Collection or object array in the model map for use as plain report parameter, rather than as report data to extract fields from, you need to specify the key for the actual report data to use, to avoid mis-detection of report data by type.
See Also:   AbstractJasperReportsView.convertReportData
See Also:   net.sf.jasperreports.engine.JRDataSource
See Also:   net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
See Also:   net.sf.jasperreports.engine.data.JRBeanArrayDataSource




setSubReportDataKeys
public void setSubReportDataKeys(String[] subReportDataKeys)(Code)
Set the list of names corresponding to the model parameters that will contain data source objects for use in sub-reports. Spring will convert these objects to instances of JRDataSource where applicable and will then include the resulting JRDataSource in the parameters passed into the JasperReports engine.

The name specified in the list should correspond to an attribute in the model Map, and to a sub-report data source parameter in your report file. If you pass in JRDataSource objects as model attributes, specifing this list of keys is not required.

If you specify a list of sub-report data keys, it is required to also specify a reportDataKey for the main report, to avoid confusion between the data source objects for the various reports involved.
Parameters:
  subReportDataKeys - list of names for sub-report data source objects
See Also:   AbstractJasperReportsView.setReportDataKey
See Also:   AbstractJasperReportsView.convertReportData
See Also:   net.sf.jasperreports.engine.JRDataSource
See Also:   net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
See Also:   net.sf.jasperreports.engine.data.JRBeanArrayDataSource




setSubReportUrls
public void setSubReportUrls(Properties subReports)(Code)
Specify resource paths which must be loaded as instances of JasperReport and passed to the JasperReports engine for rendering as sub-reports, under the same keys as in this mapping.
Parameters:
  subReports - mapping between model keys and resource paths(Spring resource locations)
See Also:   AbstractJasperReportsView.setUrl
See Also:   org.springframework.context.ApplicationContext.getResource



Methods inherited from org.springframework.web.servlet.view.AbstractUrlBasedView
public void afterPropertiesSet() throws Exception(Code)(Java Doc)
public String getUrl()(Code)(Java Doc)
public void setUrl(String url)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.