org.dbforms.servlets.reports
Class LineReportServletAbstract

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.dbforms.servlets.reports.ReportServletAbstract
              extended by org.dbforms.servlets.reports.LineReportServletAbstract
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
CSVReportServlet, ExcelReportServlet

public abstract class LineReportServletAbstract
extends ReportServletAbstract

This servlet generates a comma separated values file (CSV). Data is read from the current dbForm, a Collection or a ResultSetVector The template file is in the reports directory with a .cr extension it consists of two lines of text, the first is a list of stirngs to use as header the second a list of comma separated field names. both lines must have the same number of elements. Normally the output file will use the first row as the headers. But if no header line is provided, then no headers are output and every row is data. usage: with a simple goto button: <db:gotoButton destTable="web_parts" destination=" /reports/Artikel"/> or for one record: <db:gotoButton destTable="web_parts" keyToDestPos="currentRow" destination="/reports/Artikel" /> Servlet mapping must be set to handle all /reports by this servlet!!! <servlet/> <servlet-name/>startreport</servlet-name/> <display-name/>startreport</display-name/> <servlet-class/>org.dbforms.StartReportServlet</servlet-class/> </servlet> <servlet-mapping/> <servlet-name/>startreport</servlet-name/> <url-pattern/>/reports/</url-pattern/> </servlet-mapping> web.xml optional parameters reportdirs list of directories to search for report file reportMimeType mime type to send to browser Parameters filename=xyz.csv name the output file Support for grabbing data from a Collection or an existing ResultSetVector set session variable "jasper.input" to use a Collection object set session variable "jasper.rsv" to use a ResultSetVector object ex <c:set var="jasper.rsv" value="${rsv_xxxxx}" scope="session" />

Author:
Neal Katz
See Also:
Serialized Form

Constructor Summary
LineReportServletAbstract()
           
 
Method Summary
protected abstract  void closeStream(OutputStream out)
           
protected abstract  String getFileExtension()
           
protected abstract  String getMimeType()
           
protected  String getReportFileExtension()
           
 void init()
          Initialize this servlet.
protected abstract  void openStream(OutputStream out)
           
protected  ReportWriter processReport(String reportFileFullName, JRDataSourceAbstract dataSource, ServletContext context, HttpServletRequest request, HttpServletResponse response)
          generates a report.
protected abstract  void writeData(Object[] data)
           
protected  void writeHeader(String[] header)
           
 
Methods inherited from class org.dbforms.servlets.reports.ReportServletAbstract
compileReport, doGet, doPost, handleException, process
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineReportServletAbstract

public LineReportServletAbstract()
Method Detail

getMimeType

protected abstract String getMimeType()

getFileExtension

protected abstract String getFileExtension()

writeData

protected abstract void writeData(Object[] data)
                           throws Exception
Throws:
Exception

openStream

protected abstract void openStream(OutputStream out)
                            throws Exception
Throws:
Exception

closeStream

protected abstract void closeStream(OutputStream out)
                             throws Exception
Throws:
Exception

init

public void init()
          throws ServletException
Description copied from class: ReportServletAbstract
Initialize this servlet.

Overrides:
init in class ReportServletAbstract
Throws:
ServletException - if we cannot configure ourselves correctly

getReportFileExtension

protected String getReportFileExtension()
Specified by:
getReportFileExtension in class ReportServletAbstract

writeHeader

protected void writeHeader(String[] header)
                    throws Exception
Throws:
Exception

processReport

protected ReportWriter processReport(String reportFileFullName,
                                     JRDataSourceAbstract dataSource,
                                     ServletContext context,
                                     HttpServletRequest request,
                                     HttpServletResponse response)
generates a report.

Specified by:
processReport in class ReportServletAbstract
Parameters:
reportFileFullName - filename of report to process reportHTTPServletRequest generated by getReportFile! getReportFile should be called before fetching data, so that error handling of report not found e.g. could be processed first!
dataSource - data for the report
context - ServletContext
request - HTTPServletRequest
response - HTTPServletResponse


Copyright © 2002-2005 DbForms. All Rights Reserved.