Expresso 5-6

com.jcorporate.expresso.services.html
Class ReportPage

java.lang.Object
  extended bycom.jcorporate.expresso.services.html.HtmlElement
      extended bycom.jcorporate.expresso.services.html.ReportPage
All Implemented Interfaces:
ExpressoReport
Direct Known Subclasses:
DownloadUsers

public class ReportPage
extends HtmlElement
implements ExpressoReport

A specialized HTML Element that implements a report. Reports have headers, possibly embedded reports, possibly page breaks, and various other embedded elements.

Reports also differ from other HTML components in that they can be written directly to files if required.

Version:
$Revision: 1.14 $ $Date: 2004/11/17 20:48:18 $
Author:
Michael Nash

Field Summary
 
Fields inherited from class com.jcorporate.expresso.services.html.HtmlElement
attributes, contents, cSSClass, cSSID
 
Constructor Summary
ReportPage()
          Constructor
ReportPage(String newFileName, String newTitle)
          Constructor Create a report page for output to a file
 
Method Summary
 void addLine(String newLine)
          Add a new line to the report
protected  void addParam(String newCode, String newDescrip, String newType, String newDefaultValue)
           
 void addRow(String rowString)
          Add a new row to the report's current table
 void addTimeStamp()
          Add a date/time stamp to the report output
 void close()
          Close the report, writing the final HTML.
 void display(HttpServletRequest req, HttpServletResponse res, String charset)
           
 void display(PrintWriter out)
          Display to the screen (browser) in the normal way
protected  void display(PrintWriter out, int depth)
          depth is ignored
 void endTable()
          End the current table in the output stream of this report
 Table getCurrentTable()
          Get the current table being used by the report
protected  String getDataContext()
          Retrieve the data context for this report.
 String getDBName()
          Retrieve the db name
 Vector getDefaultParams()
          Return a Vector of default parameter objects
 String getDefaultValue(String parameterName)
          Retrieve the default parameter value for the given parameter name
protected  Page getPage()
          Return a reference to the current page
 String getParam(String paramCode)
          Return the value of the named parameter
 List getParameterNames()
          Retrieve a list of parameters that this report supports.
 Hashtable getParams()
          Return the parameters for this report
 String getReportCode()
          Retrieve the report code
 String getReportFileExtension()
          Retrieve the recommended file extension for the report.
 String getReportMimeType()
          Retrieve the report mime type.
protected  Map getReportParameters()
          Protected "getter" function so derived classes can get the report parameters
 String getTitle()
          Return the title of this report
 void populateDefaultValues()
          Dummy implementation.
 void printReport(OutputStream os)
          Print the Report Page.
 void save()
          Save output to a file
 void setDataContext(String newDataContext)
          Sets the data context for this report.
 void setDBName(String newDBName)
           
 void setFileName(String newFileName)
          Set the file name for output
 void setFileName(String newFileName, String newTitle)
          Set the filename and the title of this report
 void setParams(Hashtable newParams)
          Set the parameters for this report to the given hashtable
 void setReportCode(String newCode)
          The report code
 void setReportParameters(Map parameters)
          Sets the report parameters
 void setTitle(String newTitle)
          Set the title of this report
 void startTable(String caption, String colHeaders)
          Begin a new table in the report output stream
 
Methods inherited from class com.jcorporate.expresso.services.html.HtmlElement
add, display, finalize, getAttribute, getContentCount, getCSSClass, getName, padWithTabs, setAttribute, setCSSClass, setCSSID, setDisplayed, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReportPage

public ReportPage()
           throws HtmlException
Constructor

Throws:
HtmlException - If superclass constructor fails

ReportPage

public ReportPage(String newFileName,
                  String newTitle)
           throws HtmlException
Constructor Create a report page for output to a file

Parameters:
newFileName - Filename for output
newTitle - Title of the report
Throws:
HtmlException - If the report page cannot be created
Method Detail

setReportCode

public void setReportCode(String newCode)
The report code

Specified by:
setReportCode in interface ExpressoReport
Parameters:
newCode - java.lang.String

populateDefaultValues

public void populateDefaultValues()
                           throws DBException
Dummy implementation. Override if your report has default values to implement.

Throws:
DBException - upon error

getReportCode

public String getReportCode()
Retrieve the report code

Returns:
java.lang.String

addLine

public void addLine(String newLine)
             throws HtmlException
Add a new line to the report

Parameters:
newLine - Line to add to the report output
Throws:
HtmlException - If the line cannot be added

addParam

protected void addParam(String newCode,
                        String newDescrip,
                        String newType,
                        String newDefaultValue)
                 throws HtmlException
Parameters:
newCode - the new parameter code
newDescrip - the new description
newType - the java type
newDefaultValue - the default value
Throws:
HtmlException - upon error

addRow

public void addRow(String rowString)
            throws HtmlException
Add a new row to the report's current table

Parameters:
rowString - Pipe-seperated values, one for each column for the new row in the table
Throws:
HtmlException - A new row could not be added

addTimeStamp

public void addTimeStamp()
                  throws HtmlException
Add a date/time stamp to the report output

Throws:
HtmlException - If the date/time stampt cannot be added

close

public void close()
           throws HtmlException
Close the report, writing the final HTML. Also closes the output if we're in cgi mode

Throws:
HtmlException - If a problem occurrs saving the report

display

public void display(HttpServletRequest req,
                    HttpServletResponse res,
                    String charset)
             throws HtmlException
Throws:
HtmlException

display

public void display(PrintWriter out)
             throws HtmlException
Display to the screen (browser) in the normal way

Parameters:
out - PrintWriter to send to client
Throws:
HtmlException - If the report could not be written

display

protected void display(PrintWriter out,
                       int depth)
                throws HtmlException
depth is ignored

Specified by:
display in class HtmlElement
Parameters:
depth - the number of tabs to indent
out - the output stream
Throws:
HtmlException - upon error

endTable

public void endTable()
              throws HtmlException
End the current table in the output stream of this report

Throws:
HtmlException - If the table could not be ended correctly

getCurrentTable

public Table getCurrentTable()
                      throws HtmlException
Get the current table being used by the report

Returns:
Table HTML Table object being currently used
Throws:
HtmlException - If the current table cannot be accessed

getDBName

public String getDBName()
Retrieve the db name

Returns:
java.lang.String

getDefaultParams

public Vector getDefaultParams()
Return a Vector of default parameter objects

Returns:
Vector of default parameters

getDefaultValue

public String getDefaultValue(String parameterName)
Retrieve the default parameter value for the given parameter name

Specified by:
getDefaultValue in interface ExpressoReport
Parameters:
parameterName - the name of the parameter. Must be listed in the list of parameter names
Returns:
java.lang.String. The default parameter value. May be null.
Throws:
IllegalArgumentException - if the parameter name does not exist in the report's parameter list.

getPage

protected Page getPage()
Return a reference to the current page

Returns:
the page

getParam

public String getParam(String paramCode)
                throws HtmlException
Return the value of the named parameter

Parameters:
paramCode - of the parameter
Returns:
Value of the given parameter
Throws:
HtmlException - if there is no such parameter

getParams

public Hashtable getParams()
                    throws HtmlException
Return the parameters for this report

Returns:
Hashtable of Parameters of this report
Throws:
HtmlException - If an error occurs retrieving the parameters

getTitle

public String getTitle()
Return the title of this report

Specified by:
getTitle in interface ExpressoReport
Returns:
Report title of this report

save

public void save()
          throws HtmlException
Save output to a file

Throws:
HtmlException - If the output could not be written

setDBName

public void setDBName(String newDBName)
Parameters:
newDBName - new data context

setFileName

public void setFileName(String newFileName)
                 throws HtmlException
Set the file name for output

Parameters:
newFileName - New output file name
Throws:
HtmlException - If the parameter is invalid

setFileName

public void setFileName(String newFileName,
                        String newTitle)
                 throws HtmlException
Set the filename and the title of this report

Parameters:
newFileName - Name of the output file to write
newTitle - Title of the report
Throws:
HtmlException - If the parameters are not valid

setParams

public void setParams(Hashtable newParams)
               throws HtmlException
Set the parameters for this report to the given hashtable

Parameters:
newParams - New parameters hashtable
Throws:
HtmlException - If these parameters cannot be set

setTitle

public void setTitle(String newTitle)
Set the title of this report

Parameters:
newTitle - New title of report

startTable

public void startTable(String caption,
                       String colHeaders)
                throws HtmlException
Begin a new table in the report output stream

Parameters:
caption - Caption for the table
colHeaders - A pipe-seperated list of column headers
Throws:
HtmlException - A new table could not be started

printReport

public void printReport(OutputStream os)
                 throws ReportException,
                        IOException
Print the Report Page. Override this in your own derived class to provide custom printing. Otherwise, this just calls the display() function to maintain backwards compatibility

Specified by:
printReport in interface ExpressoReport
Parameters:
os - The OutputStream to send to.
Throws:
ReportException - upon error.
IOException - upon IO error

setReportParameters

public void setReportParameters(Map parameters)
Sets the report parameters

Specified by:
setReportParameters in interface ExpressoReport
Parameters:
parameters - Map of parameters

getReportParameters

protected Map getReportParameters()
Protected "getter" function so derived classes can get the report parameters

Returns:
java.util.Map

setDataContext

public void setDataContext(String newDataContext)
Sets the data context for this report.

Specified by:
setDataContext in interface ExpressoReport
Parameters:
newDataContext - the new data context

getDataContext

protected String getDataContext()
Retrieve the data context for this report.

Returns:
java.lang.String

getReportMimeType

public String getReportMimeType()
Retrieve the report mime type. In this case, HTML text.

Specified by:
getReportMimeType in interface ExpressoReport
Returns:
java.lang.String: "text/html"
See Also:
MimeTypes

getReportFileExtension

public String getReportFileExtension()
Retrieve the recommended file extension for the report. Return the value without the '.'. So an example file extension for an Excel report would be "xls", and XML formatted report would be "xml" [although if you're using special XML languages, of course you have the freedom to specify the extension]

Specified by:
getReportFileExtension in interface ExpressoReport
Returns:
java.lang.String in the format specified above.

getParameterNames

public List getParameterNames()
Retrieve a list of parameters that this report supports. This function may be blank, in which case, there still could be parameters for the report but the automatic ui functions such as ReportServer won't present them as options.

Specified by:
getParameterNames in interface ExpressoReport
Returns:
java.util.List of Strings. or null if there are no parameters

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.