Upgrade to v2

WebDAV Ajax Library v2 provides a new approach to opening documents for editing based on protocols. The Java applet used in the previous versions is deprecated and replaced with native OS protocol handlers which provide improved performance and run consistently in all web browsers including Chrome and Safari on Windows, OS X and Linux.

Because the web browser NPAPI is considered obsolete there is no way to run Java applets as well as to detect if Microsoft Office is installed on a client machine or detect Microsoft Office version. However with a new API this is not required, you can successfully open both MS Office and non-MS Office documents from a web page as well as you can detect if the protocol is installed using a callback function and provide a UI to offer a protocol installer download.

Upgrading EditDocument() Function Call

As with v1.x to open documents in most cases you will use DocManager.EditDocument() function with v2.x. However, its parameters have changed. The EditDocument() function now provides 3 parameters:

  • sDocumentUrl – document to open. This could be either MS Office document or any other type of a document. Semantics of this parameter did not change comparing to v1.x.
  • sMountUrl - Url to mount the file system to before opening the folder. Usually, this is your WebDAV server root folder. If this parameter is not specified file system will be mounted to the folder in which document is located.
  • errorCallback – a callback function that will be called if opening a document failed. In this callback, you will typically request a protocol installation and will redirect to the installer that targets client OS.

Because every OS requires a different installer the IT Hit WebDAV Ajax Client library now provides DocManager.GetInstallFileName() function that returns installer file name depending on OS on which the client code is executed. Here is how your typical document opening code will look like:

function editDoc() {
   ITHit.WebDAV.Client.DocManager.EditDocument(
       "http://localhost:87654/folder/file.ext", “/”, protocolInstallCallback);
}

function protocolInstallCallback(message) {
   var installerFilePath = "/Plugins/" + ITHit.WebDAV.Client.DocManager.GetInstallFileName();
 
   if (confirm("Select OK to download the protocol installer.")){
      window.open(installerFilePath);
   }
}

If you did not update your code and passing .jar file URL as a second parameter you will see a JavaScript confirmation dialog recommending to update your code and redirecting to this document.

Similarly to OpenDocument() function other functions such as the OpenFolderInOsFileManager() and MicrosoftOfficeEditDocument() now provide a callback function to be executed if call failed. As with OpenDocument() you will typically request protocol installation:

function openFolder() {
   ITHit.WebDAV.Client.DocManager.OpenFolderInOsFileManager(
       "http://localhost:87654/folder/", “/”, protocolInstallCallback);
}

function editMsOfficeDoc() {
   ITHit.WebDAV.Client.DocManager.MicrosoftOfficeEditDocument(
       "http://localhost:87654/folder/file.docx", protocolInstallCallback);
}

Note that if MS Office is not installed, the MicrosoftOfficeEditDocument() function calls an error callback passed as a second parameter. In this callback, you can call DavProtocolEditDocument() function which will try to open the document with associated application, for example with LibreOffice.

Deprecated API

The following JavaScript functions are deprecated:

Deprecated functionReplaced with
JavaEditDocument() DavProtocolEditDocument()
JavaOpenFolderInOsFileManager() None, use OpenFolderInOsFileManager() instead.
IsMicrosoftOfficeAvailable() None
GetMsOfficeVersion() None
ShowMicrosoftOfficeWarning() None

 

The JavaEditDocument() and JavaOpenFolderInOsFileManager() functions are still present in the DocManager API, however their implementation calls DavProtocolEditDocument() and OpenFolderInOsFileManager() functions. The Java applet parameter URL (sJavaAppletUrl, 3rd parameter) is being used as a hint to where to find the protocol installers as they are located in the same folder where jar file was located (/Plugins/). These methods also show “deprecated” warning with a link to these upgrade instructions.