org.wicketstuff.jasperreports
Class JRResource

java.lang.Object
  extended by org.apache.wicket.Resource
      extended by org.apache.wicket.markup.html.WebResource
          extended by org.apache.wicket.markup.html.DynamicWebResource
              extended by org.wicketstuff.jasperreports.JRResource
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IRequestListener, org.apache.wicket.IResourceListener
Direct Known Subclasses:
JRConcreteResource, JRImageResource

public abstract class JRResource
extends org.apache.wicket.markup.html.DynamicWebResource

Base class for jasper reports resources.

Author:
Eelco Hillenius, Matej Knopp, Luciano Montebove
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.DynamicWebResource
org.apache.wicket.markup.html.DynamicWebResource.ResourceState
 
Field Summary
 
Fields inherited from interface org.apache.wicket.IResourceListener
INTERFACE
 
Constructor Summary
JRResource()
          Construct without a report.
JRResource(java.io.File report)
          Construct.
JRResource(IJasperReportFactory factory)
          Construct.
JRResource(java.io.InputStream report)
          Construct.
JRResource(java.net.URL report)
          Construct.
 
Method Summary
 IDatabaseConnectionProvider getConnectionProvider()
          Gets the connection provider if any for filling this report.
abstract  java.lang.String getContentType()
           
abstract  java.lang.String getExtension()
          Returns the extension for the resource's file.
 java.lang.String getFileName()
          Gets the file name.
 net.sf.jasperreports.engine.JasperReport getJasperReport()
          Gets jasperReport.
 net.sf.jasperreports.engine.JRDataSource getReportDataSource()
          Gets the datasource if any for filling this report.
 java.util.Map getReportParameters()
          Gets the report parameters.
protected  org.apache.wicket.markup.html.DynamicWebResource.ResourceState getResourceState()
          Gets the binary data by getting a new instance of JasperPrint and an exporter for generating the output.
abstract  net.sf.jasperreports.engine.JRAbstractExporter newExporter()
          Called by getData to obtain an exporter instance.
protected  net.sf.jasperreports.engine.JasperPrint newJasperPrint()
          Creates a new JasperPrint instance.
 JRResource setConnectionProvider(IDatabaseConnectionProvider provider)
          Sets the connection provider if any for filling this report.
 JRResource setFileName(java.lang.String name)
          Sets the file name.
protected  void setHeaders(org.apache.wicket.protocol.http.WebResponse response)
           
 void setJasperReport(net.sf.jasperreports.engine.JasperReport report)
          Sets {bjasperReport.
 JRResource setReportDataSource(net.sf.jasperreports.engine.JRDataSource dataSource)
          Sets the datasource if any for filling this report.
 JRResource setReportParameters(java.util.Map params)
          Sets the report parameters.
 
Methods inherited from class org.apache.wicket.markup.html.DynamicWebResource
getLocale, getResourceStream
 
Methods inherited from class org.apache.wicket.markup.html.WebResource
configureResponse, getCacheDuration
 
Methods inherited from class org.apache.wicket.Resource
getParameters, invalidate, isCacheable, onResourceRequested, setCacheable, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRResource

public JRResource()
Construct without a report. You must provide a report before you can use this resource.


JRResource

public JRResource(java.io.InputStream report)
Construct.

Parameters:
report - the report input stream

JRResource

public JRResource(java.net.URL report)
Construct.

Parameters:
report - the report input stream

JRResource

public JRResource(java.io.File report)
Construct.

Parameters:
report - the report input stream

JRResource

public JRResource(IJasperReportFactory factory)
Construct.

Parameters:
factory - report factory for lazy initialization
Method Detail

getJasperReport

public net.sf.jasperreports.engine.JasperReport getJasperReport()
Gets jasperReport. This implementation uses an internal factory to lazily create the report. After creation the report is cached (set as the jasperReport property). Override this method in case you want to provide some alternative creation/ caching scheme.

Returns:
jasperReport

setJasperReport

public final void setJasperReport(net.sf.jasperreports.engine.JasperReport report)
Sets {bjasperReport.

Parameters:
report - report

getReportParameters

public java.util.Map getReportParameters()
Gets the report parameters. Returns a new copy of the reportParameters Map as JasperReports modifies it with not serializable objects

Returns:
report parameters

setReportParameters

public final JRResource setReportParameters(java.util.Map params)
Sets the report parameters.

Parameters:
params - report parameters
Returns:
This

getReportDataSource

public net.sf.jasperreports.engine.JRDataSource getReportDataSource()
Gets the datasource if any for filling this report.

Returns:
the datasource if any for filling this report

setReportDataSource

public JRResource setReportDataSource(net.sf.jasperreports.engine.JRDataSource dataSource)
Sets the datasource if any for filling this report.

Parameters:
dataSource - the datasource if any for filling this report
Returns:
This

getConnectionProvider

public IDatabaseConnectionProvider getConnectionProvider()
Gets the connection provider if any for filling this report.

Returns:
the connection provider if any for filling this report

setConnectionProvider

public final JRResource setConnectionProvider(IDatabaseConnectionProvider provider)
Sets the connection provider if any for filling this report.

Parameters:
provider - the connection provider if any for filling this report
Returns:
This

getFileName

public java.lang.String getFileName()
Gets the file name. When set, a header 'Content-Disposition: attachment; filename="${fileName}"' will be added to the response, resulting in a download dialog. No magical extensions are added, so you should make sure the file has the extension you want yourself.

Returns:
the file name

setFileName

public final JRResource setFileName(java.lang.String name)
Sets the file name. When set, a header 'Content-Disposition: attachment; filename="${name}"' will be added to the response, resulting in a download dialog. No magical extensions are added, so you should make sure the file has the extension you want yourself.

Parameters:
name - the file name
Returns:
This

newExporter

public abstract net.sf.jasperreports.engine.JRAbstractExporter newExporter()
Called by getData to obtain an exporter instance.

Returns:
an exporter instance

getResourceState

protected org.apache.wicket.markup.html.DynamicWebResource.ResourceState getResourceState()
Gets the binary data by getting a new instance of JasperPrint and an exporter for generating the output.

Specified by:
getResourceState in class org.apache.wicket.markup.html.DynamicWebResource
Returns:
the binary data
See Also:
DynamicWebResource.getResourceState()

getContentType

public abstract java.lang.String getContentType()
Returns:
The content type of the reports

getExtension

public abstract java.lang.String getExtension()
Returns the extension for the resource's file. This string should not contain the leading "."

Returns:
The extension for the resource's file.

newJasperPrint

protected net.sf.jasperreports.engine.JasperPrint newJasperPrint()
                                                          throws net.sf.jasperreports.engine.JRException
Creates a new JasperPrint instance. This instance is specific for this render, but it not yet designated for one output format only.

Returns:
a new JasperPrint instance.
Throws:
net.sf.jasperreports.engine.JRException

setHeaders

protected void setHeaders(org.apache.wicket.protocol.http.WebResponse response)
Overrides:
setHeaders in class org.apache.wicket.markup.html.DynamicWebResource
See Also:
WebResource.setHeaders(WebResponse)


Copyright © 2005-2010 Wicket developers. All Rights Reserved.