Defining a custom Content Handler
The document content handler/connector that VirtualViewer will use is set using the contentHandlerClass
parameter in the application’s web.xml
file. Many customers create a custom content handler class that integrates with their document management and security systems.
The Content Handler APIS are now documented in our Javdocs located on our website at https://docs.snowbound.com/virtualviewer/5.1.0/java/content-handler-api/. Also useful are the sample files found in in the VirtualViewer .war
file under \Sample Code\Java Content Handler\FileContentHandler.java
in your build directory.
Please see the following example for specifying a custom content handler:
<init-param>
<param-name>contentHandlerClass</param-name>
<param-value>com.snowbound.VirtualViewer.custom.MyContentHandler</param-value>
</init-param>
<param-name>contentHandlerClass</param-name>
<param-value>com.mycompany.viewer.DocumentConnector</param-value>
VirtualViewer would then look for and invoke your custom content handler at ./WEB-INF/classes/com/mycompany/viewer/DocumentConnector.class.
To use the sample/default File Connector specify:
<param-name>contentHandlerClass</param-name>
<param-value>com.snowbound.VirtualViewer.FileContentHandler</paramvalue>
<param name="filePath" value="C:/MyDocuments"/> // folder on the server
<param name='startFile' value='myLogo.gif'> // will display C:/MyDocuments/myLogo.gif in the client at start up
The source code for the sample file content handler is provided as a starting point for your own custom connector. The code is located in the VirtualViewer .war
file under \Sample Code\Java Content Handler\FileContentHandler.java.
VirtualViewerContentHandlerInterface
This interface defines methods for retrieving content for VirtualViewer HTML5 for Java.
Most of the methods take in a single input parameter, which is an instance of the class ContentHandlerInput
, an extension of java.util.Hashtable
which contains the data that is required to implement each method.
Likewise, most of the methods return a single value, which is an instance of the class ContentHandlerResult
, also and an extension of java.util.Hashtable
which contains the data required to complete the method.
Have questions, corrections, or concerns about this topic? Please let us know!