Blog: Tech Talk

agsdix-fas fa-home

Blog: Home

agsdix-fas fa-pen-fancy

Blog: CEO's Corner

agsdix-fas fa-code

Blog: Tech Talk

Blog: Product Releases

Blog: Conversion

arrow left circle icon Blog: Tech Talk

Using Event Notifications in VirtualViewer Java AJAX

by | Apr 24, 2012

Snowbound Software’s VirtualViewer Java AJAX product makes use of the VirtualViewer Content Handler to perform various actions concerning the retrieval and storage of content. By default, the VirtualViewer server uses FileContentHandler as its Content Handler, which merely reads and writes to a file system location. However, a different, custom class may be implemented in order to integrate VirtualViewer into a myriad of back-end systems. 

In addition to these storage and retrieval calls, the Content Handler can also be used to process various event notifications. You can provide function “hooks” that will get called when certain events happen such as viewing, saving, exporting or printing a page in a document. Your function can then record the user and the event into your auditing or privacy compliance system. You add these hook functions into your Content Handler.


This interface defines methods that are generally used for retrieving content for VirtualViewer. Most of the methods have a single input parameter which is an instance of the class ContentHandlerInput (an extension of java.util.Hashtable).

Most of the methods return an instance of the class ContentHandlerResult (also an extension of java.util.Hashtable) which contains the return data required by the method.

For more information on setting up the Content Handler, please see Chapter 4 – Working with the Content Handler in the VirtualViewer Java Content Server Administrator’s Guide.

To use the eventNotification method to set up event notifications in the Content Handler, please see the description of the eventNotification method below:

Method Detail



public ContentHandlerResult eventNotification (ContentHandlerInput input) throws FlexSnapSIAPIException

Implement this content handler method to receive event notifications.


A ContentHandlerInput object containing the following data:

KEY_EVENTStringOne of the following four VALUE_EVENT_* values:
VALUE_EVENT_PAGE_REQUESTED  Indicates that a page has been requested to be viewed.
VALUE_EVENT_SAVE_ANNOTATION  Indicates that an annotation layer has been saved.
Indicates that a document has been printed.  
Indicates that a document has been exported. 
 VALUE_EVENT_PAGE_REQUESTEDStringThe event being logged is a page request
KEY_EVENT_PAGE_REQUESTED_NUMBERStringThe page number requested (zero-based)
VALUE_EVENT_SAVE_ANNOTATIONStringThe event being logged is a save annotation request


A ContentHandlerResult object or null. The return value is currently ignored.

Sample Implementation

The following is a code sample showing how to implement the event notification feature:

public ContentHandlerResult eventNotification(ContentHandlerInput input)

        throws FlexSnapSIAPIException


        String eventName = (String) input.get(ContentHandlerResult.KEY_EVENT);

        if(eventName.indexOf(ContentHandlerResult.VALUE_EVENT_PAGE_REQUESTED) != -1) {

            String pageNumber = (String) input.get(ContentHandlerResult.KEY_EVENT_PAGE_REQUESTED_NUMBER);

            System.out.println(“===========Page Requested: ” + pageNumber);


        return ContentHandlerResult.VOID;


Defining the Content Handler

The VirtualViewer servlet will instantiate the Content Handler class that is specified in the application’s web.xml using the parameter contentHandlerClass. For example: