org.wicketstuff.jasperreports
Class JRResource

java.lang.Object
  extended by org.apache.wicket.request.resource.AbstractResource
      extended by org.wicketstuff.jasperreports.JRResource
All Implemented Interfaces:
Serializable, org.apache.wicket.request.resource.IResource
Direct Known Subclasses:
JRConcreteResource, JRImageResource

public abstract class JRResource
extends org.apache.wicket.request.resource.AbstractResource

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.request.resource.AbstractResource
org.apache.wicket.request.resource.AbstractResource.ResourceResponse, org.apache.wicket.request.resource.AbstractResource.WriteCallback
 
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
org.apache.wicket.request.resource.IResource.Attributes
 
Constructor Summary
JRResource()
          Construct without a report.
JRResource(File report)
          Construct.
JRResource(IJasperReportFactory factory)
          Construct.
JRResource(InputStream report)
          Construct.
JRResource(URL report)
          Construct.
 
Method Summary
 IDatabaseConnectionProvider getConnectionProvider()
          Gets the connection provider if any for filling this report.
 org.apache.wicket.request.resource.ContentDisposition getContentDisposition()
          The default is to return the content as an attachment.
abstract  String getContentType()
           
protected  byte[] getExporterData(net.sf.jasperreports.engine.JasperPrint print, net.sf.jasperreports.engine.JRAbstractExporter exporter)
           
abstract  String getExtension()
          Returns the extension for the resource's file.
 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.
 Map<String,Object> getReportParameters()
          Gets the report parameters.
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.
protected  org.apache.wicket.request.resource.AbstractResource.ResourceResponse newResourceResponse(org.apache.wicket.request.resource.IResource.Attributes attributes)
           
 JRResource setConnectionProvider(IDatabaseConnectionProvider provider)
          Sets the connection provider if any for filling this report.
 JRResource setFileName(String name)
          Sets the file name.
 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(Map<String,Object> params)
          Sets the report parameters.
 
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, respond
 
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(InputStream report)
Construct.

Parameters:
report - the report input stream

JRResource

public JRResource(URL report)
Construct.

Parameters:
report - the report input stream

JRResource

public JRResource(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 Map<String,Object> 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(Map<String,Object> 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 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(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

getContentType

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

getContentDisposition

public org.apache.wicket.request.resource.ContentDisposition getContentDisposition()
The default is to return the content as an attachment.

Returns:
The content disposition of the reports

getExtension

public abstract 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

newResourceResponse

protected org.apache.wicket.request.resource.AbstractResource.ResourceResponse newResourceResponse(org.apache.wicket.request.resource.IResource.Attributes attributes)
Specified by:
newResourceResponse in class org.apache.wicket.request.resource.AbstractResource

getExporterData

protected byte[] getExporterData(net.sf.jasperreports.engine.JasperPrint print,
                                 net.sf.jasperreports.engine.JRAbstractExporter exporter)
                          throws net.sf.jasperreports.engine.JRException
Throws:
net.sf.jasperreports.engine.JRException


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