com.interface21.web.servlet.view.document
Class AbstractPdfView

java.lang.Object
  |
  +--com.interface21.context.support.ApplicationObjectSupport
        |
        +--com.interface21.web.servlet.view.AbstractView
              |
              +--com.interface21.web.servlet.view.document.AbstractPdfView
All Implemented Interfaces:
ApplicationContextAware, View

public abstract class AbstractPdfView
extends AbstractView

Abstract superclass for PDF views, using Bruno Lowagie's iText package. Application-specific view classes will extend this class. The view will be held in such a subclass, not a template such as a JSP.
See Expert One-On-One J2EE Design and Development by Rod Johnson, pp 571-575 for an example of use of this class.
NB: Internet Explorer requires a .pdf extension, as it doesn't always respect the declared content type.
Exposes page width and height as bean properties.

Version:
$Id: AbstractPdfView.java,v 1.1 2003/06/25 16:26:50 jhoeller Exp $
Author:
Rod Johnson

Fields inherited from class com.interface21.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractPdfView()
          Set the appropriate content type.
 
Method Summary
protected abstract  void buildPdfDocument(java.util.Map model, com.lowagie.text.Document pdfDoc, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Subclasses must implement this method to create an iText PDF document, given the model.
protected  void renderMergedOutputModel(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Subclasses must implement this method to render the view.
 void setHeight(int height)
          TODO: bean property not currently used
 void setWidth(int width)
          TODO: bean property not currently used
 
Methods inherited from class com.interface21.web.servlet.view.AbstractView
addStaticAttribute, getContentType, getName, getStaticAttributes, render, setAttributes, setAttributesCSV, setContentType, setName, setRequestContextAttribute
 
Methods inherited from class com.interface21.context.support.ApplicationObjectSupport
getApplicationContext, initApplicationContext, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPdfView

public AbstractPdfView()
Set the appropriate content type. Note that IE won't take much notice of this, but there's not a lot we can do about this. Generated documents should have a .pdf extension.
Method Detail

setWidth

public void setWidth(int width)
TODO: bean property not currently used

setHeight

public void setHeight(int height)
TODO: bean property not currently used

renderMergedOutputModel

protected final void renderMergedOutputModel(java.util.Map model,
                                             javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response)
                                      throws javax.servlet.ServletException,
                                             java.io.IOException
Description copied from class: AbstractView
Subclasses must implement this method to render the view.

The first take will be preparing the request: This may include setting the model elements as attributes, e.g. in the case of a JSP view.

Overrides:
renderMergedOutputModel in class AbstractView
See Also:
AbstractView.renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

buildPdfDocument

protected abstract void buildPdfDocument(java.util.Map model,
                                         com.lowagie.text.Document pdfDoc,
                                         javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response)
                                  throws com.lowagie.text.DocumentException
Subclasses must implement this method to create an iText PDF document, given the model.
Parameters:
request - in case we need locale etc. Shouldn't look at attributes
response - in case we need to set cookies. Shouldn't write to it.


Rod Johnson and Spring contributors 2001-2003.