Deployment Best Practices
Quick Deploy
The deployment examples on this site use the open source JavaScript library Applet-Fu when deploying applets. This library greatly simplifies the deployment of applets in general, and ChemWriter in particular.
To use this method, your deployment environment should include the files chemwriter.jar, applet_fu.js, and an image file called 'no-java.png' which are accessible from your application's public directory.
The following HTML will create a page containing a 550x320 instance of ChemWriter:
<html>
<head>
<script type="text/javascript" src="easyapplet.js"></script>
</head>
<body>
<script type='text/javascript'>
applet_fu.run(
{'width':'550','height':'320'},
{
'archive':'chemwriter.jar',
'code':'com/metamolecular/chemwriter/applet/EditorApplet.class',
'licenseKey':'D7D4-1D2B-B43C-078F-ACF9-F1F6'
},
'1.4.2',
'<img src="/no-java.png" />'
);
</script>
</body>
</html>
The JavaScript method applet_fu.run accepts four parameters:
- A hash specifying the applet's width and height parameters.
- A hash specifying startup parameters, only two of which are required: (1) 'archive' (the path to the ChemWriter jarfile); and (2) 'code', the fully-qualified name of the Applet class to be run. Additional parameters, such as your license key, can be included as well.
- The minimum version of the Java plugin on the client. This can be set to any version greater than or equal to 1.4.2.
- Fallback content to be displayed to the client in the event that the Java plugin is unavailable.
Invoking applet_fu.run creates a browser-specific <object> tag structure (see below) through the use of JavaScript's document.write function.
This preferred deployment method prevents ChemWriter from being disabled on startup in some versions of Microsoft Internet Explorer. The disablement consists of a dashed border and popup messages that states ('Click to activate and use this control'). This mechanism for loading browser plugins was introduced by Microsoft as a result of losing the Eolas Patent Case. The most recent versions of Internet Explorer eliminate the Eolas disablement feature.

Deployment Using HTML Only
ChemWriter can also be deployed without JavaScript by using HTML similar to that given below:
<!--[if IE]><object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0" width="550" height="320"><script>/*<![endif]--><script type="text/javascript">/**/</script> <!--[if !IE]><!--> <object type="application/x-java-applet;version=1.4.2" width="550" height="320"> <!--<![endif]--> <param name="code" value="com/metamolecular/chemwriter/applet/EditorApplet.class"> <param name="archive" value="chemwriter.jar"> <param name="licenseKey" value="D7D4-1D2B-B43C-078F-ACF9-F1F6"> <img src="no-java.png"/> </object>
In this method, Internet Explorer conditional comments are used for creating an Explorer-specific <object> tag structure. This method was adapted from similar approaches used to deploy Adobe Flash content using valid XHTML.
Compatibility
The methods described above have been tested and are known to work on: Microsoft Internet Explorer 6/7/8 (Windows); Firefox 2/3 (Windows, Mac OS X, Linux); Safari 3 (Mac OS X); Google Chrome (Windows); and Opera (Windows, Mac OS X, Linux) using Java 1.4/1.5/1.6. Browsers, operating systems, and the Java plugin each are offered in numerous incremental revisions ("minor revisions"). As such, it is impossible to guarantee the effectiveness of this method with every combination of minor revision.
If you exprience any problems in deploying ChemWriter to all of your target platforms, please contact us.
