PEERNET Reports Applet

 

The PEERNET Reports Applet is a java applet that gets embedded in a web page to provide automated print functionalty, file drop functionality or preview of reports or labels, and other functions that need to occur on the client’s machine.

 

PEERNET Reports Applet is a form of AJAX support.

 

To embed the PEERNET Reports Applet into a web page you need to use the HTML APPLET tag of the form:

 

<APPLET ARCHIVE=http://<webserver>:<port>/.../PEERNETReportsApplet1.jar  

CODE="com.peernet.PeernetReportApplet1.PeernetReportApplet1.class">

   PEERNET Reports Applet requires Sun Java Plugin 1.4 or better!

</APPLET>

 

As with any applet you can specify the NAME, WIDTH, HEIGHT attributes.   Refer to your HTML APPLET tag documentation for further information on these attributes.

 

 

The PEERNET Reports Applet allows for the following additional parameters to be passed to the applet:

 

Name

Description

DEBUG

Turns on or off debugging information that is displayed in the java console.

 

Values:

True or False

Yes or No

 

Example:

<param name="DEBUG" value="true" />

PREVIEW

Turns on previewing of a report or label.  When previewing is enabled, automatic printing is turned off and the users must press the print button on the print preview window in order to print the report or label.

 

Values:

True or False

Yes or No

 

<param name="PREVIEW" value="true" />

ZOOMTOFIT

Turns on zoom to fit of a report or label into the preview window.   This options is ignored with not previewing the report or label.

 

Values:

True or False

Yes or No

 

Example:

<param name=" ZOOMTOFIT " value="true" />

SRC

This parameter provides the URL where the applet will retrieve the information required for this operation.

 

If the applet is printing or previewing a report or label this must be a URL that returns the PEERNET Print Applet language.

 

If you are using the applet to copy information from the server to a port or file on the client machine, then the URL can return any type of data.

 

Example:

<param name="SRC” value="http://<webserver>:<port>/PEERNETReportsServer3/

PEERNETReportsServerRequestServlet?

PROJECT=<project>&REQUEST=<request>" />

PORT

This parameter is a port or file name on the client machine.

 

When a PORT is specified, the applet performs a file copy operation from the source to the specified PORT.  No interpretation of the data is made.  This is a binary copy operation.

 

Values:

A valid port name installed on the client machine.

 

Example:

<param name=" PORT " value="COM1:" />

or

<param name=" PORT " value="C:/dropfile.txt" />

PRINTER

This parameter specifies the target printer when printing a report or label using the PEERNET Print Applet language.

 

Values:

A valid printer name installed on the client machine.

 

Example:

<param name=" PRINTER " value="HP LaserJet 4050" />

SHOWPRINTERDIALOG

This parameter specifies the print selection dialog will appear when printing a report or label using the PEERNET Print Applet language.

 

If the PRINTER parameter specifies a printer, this will be the initially selected printer otherwise, the default printer will be initially selected.

 

Values:

True or False

Yes or No

 

Example:

<param name="SHOWPRINTERDIALOG" value="true" />

FontForMsgs

Font used to display text in dialog and message boxes displayed by the applet.

TitleForMsgs

Title to display in dialog and message boxes

PrintConfirmationMsg

Confirmation message to display to confirm print action is to be performed.

 

If no PrintConfirmationMsg is provided, then this confirmation is not preformed.

PrintPickupMsg

Pickup message to display after print action has completed.

 

 

If no PrintPickupMsg is provided, then this pickup confirmation is not preformed.

OkayButtonText

The text to be displayed on the Okay button.  Default is OKAY.

CancelButtonText

The text to be displayed on the Cancel button. Default is Cancel.

RetryButtonText

The text to be displayed on the Retry button. Default is Retry.

 

In addition to the parameters, the PEERNET Report Applet may be accessed using JavaScript.

 

There are several APIs that may be call from JavaScript depending on your usage.

 

Method:

 

 public synchronized void copyToPort( String url, String port )

 

Description:

 

 The url can be any type of file.   The port can be any valid port or file location that is valid for the client machine.

 

Purpose:

 The purpose of the method is to allow a file to be transferred in binary mode from the server to the client.

 

 For example, you may have a requirement where you produce native printer code (PostScript, Zebra, PCL, etc) and wish to send this directly to the printer.   To accomplish this, you would copy from the url to the port

 

       <yourappletname>.copyToPort( "http://...", "LPT1:")

 

 

 For example, you may have a requirement where copy a file from your server to a file on the client’s machine copy from the url to the file

 

       <yourappletname>.copyToPort( "http://...", "c:/dropfile.pdf")

 

 

Method:

 

 public synchronized void printReport( String url, String printer, boolean bShowPrintDialog )

 

Description:

 

 The url can only PEERNET Print Applet content.   The printer can be any valid printer installed on client machine or null (meaning use default printer). The bShowPrintDialog can be true or false and controls whether the print dialog is displayed during the print process.

 

 

Purpose:

 The purpose of the method is to allow a PEERNET Request whose convert to operation is setup to use the PEERNET Print Applet as its target to be printed on the client computer using the PEERNET Reports Applet.  This operation can be performed with or without user interaction.

 

 

// Specifies the printer and print’s without user interaction

       <yourappletname>.printReport( "http://...", "HP LasertJet 4050", false )

 

// Does not specify a printer so the default printer will be used

// and then specifies to prompt with the printer selection dialog

       <yourappletname>.printReport( "http://...", null, true )

 

Method:

 

 public synchronized void previewReport( String url, String printer, boolean bShowPrintDialog, boolean bZoomToFit )

 

Description:

 

 The url can only PEERNET Print Applet content.   The printer can be any valid printer installed on client machine or null (meaning use default printer). The bShowPrintDialog can be true or false and controls whether the print dialog is displayed during the print process.  The bZoomToFit can be true or false and controls whether the previewed report or label is zoomed to fit by default in the print preview window.

 

 

Purpose:

 The purpose of the method is to allow a PEERNET Request whose convert to operation is setup to use the PEERNET Print Applet as its target to be previewed on the client computer using the PEERNET Reports Applet.  From the preview window the client can page through the pages of the report or label and/or initate a print operation.

 

Method:

 

 public long getStatus()

 

Description:

 

 This method is used to get the status of the current printReport or previewReport operation.

 

 The return is a long contain a set of flags that indicate the status of the operation:

 

 0 means no action is currently being performed.

 

 (1 & getStatus()) means url is being downloaded from the server.

 

 (2 & getStatus()) means url is has been downloaded from the server successfully.

 

 (4 & getStatus()) means url is has been downloaded from the server unsuccessfully.

 

 (16 & getStatus()) means the downloaded document is printing.

 

 (32 & getStatus()) means the downloaded document has been  printed successfully.

 

 (64 & getStatus()) means the downloaded document has been printed unsuccessfully.

 

Purpose:

 The purpose of the method is to allow the JavaScript method that calls printReport or previewReport method to know the status of the operation.  It’s mostly used for the printReport method.

 

 

Examples:

 

function PrintDocument( showdialog )

{

 

   cmd = "http://<webserver>:<port>/PEERNETReportsServer3/PEERNETReportsServerRequestServlet?PROJECT=<project>&REQUEST=<request>";

 

 document.PEERNETReportsApplet2.printReport( cmd, null, showdialog ) ;

 

 status2 = document.PEERNETReportsApplet2.getStatus() ;

 

 //        Wait for load of document to complete

 while ( status2 & 1 )

         status2 = document.PEERNETReportsApplet2.getStatus() ;

         

 // Wait for document to be sent to the printer

 while( status2 & 16)

         status2 = document.PEERNETReportsApplet2.getStatus() ;

 

 state = "No Status" ;

 

 if ( status2 & 1 )

          state = "Loading document from specified location" ;

 if ( status2 & 2 )

          state = "Finished Loading document from specified location" ;

 if ( status2 & 4 )

          state = "Failed to load document from specified location" ;

 

 if ( status2 & 16 )

          state = "Printing the document " ;

 if ( status2 & 32 )

          state = "Finished printing the document " ;

 if ( status2 & 64 )

          state = "Failed to print the document " ;

 

}

 

function LoadDocument()

{

 

   cmd = "http://<webserver>:<port>/PEERNETReportsServer3/PEERNETReportsServerRequestServlet?PROJECT=<project>&REQUEST=<request>";

 

 document.PEERNETReportsApplet1.previewReport( cmd, null, false ) ;

 

 status2 = document.PEERNETReportsApplet1.getStatus() ;

 

 //        Wait for load of document to complete

 while ( status2 & 1 )

         status2 = document.PEERNETReportsApplet1.getStatus() ;

         

 state = "No Status" ;

 

 if ( status2 & 1 )

          state = "Loading document from specified location" ;

 if ( status2 & 2 )

          state = "Finished Loading document from specified location" ;

 if ( status2 & 4 )

          state = "Failed to load document from specified location" ;

 

}

 

Method:

 

 public String getDefaultPrinter()

 

Description:

 

 This method returns the default printer on the client’s machine.

 

This method does not work on all browsers but is known to work on IE5+, Firefox, and Mozilla with Java 1.4+.

 

Purpose:

 The purpose of the method is to allow JavaScript to know the name of the default printer.

 

 

Method:

 

 public int getPrinterCount()

 

Description:

 

 This method returns the total number of installed printers on the client’s machine.

 

This method does not work on all browsers but is known to work on IE5+, Firefox, and Mozilla with Java 1.4+.

 

Purpose:

 The purpose of the method is to allow you know the total number of installed printers on the client’s machine.

 

 

Method:

 

 public String getPrinter( int index )

 

Description:

 

 This method returns the name of an installed printer on the client’s machine given a index between 0 and (getPrinterCount()-1).

 

This method does not work on all browsers but is known to work on IE5+, Firefox, and Mozilla with Java 1.4+.

 

Purpose:

 The purpose of the method is to allow retrieve the names of all the installed printers on the client’s machine.