#537 jsvApplet._applet remains null after Jmol.getJSVApplet

Bob Hanson
Applet (71)
Tim te Beek

Trying to get JSpecView and Jmol to interact using the new JavaScripts, I'm unable to get jspecView to show and load data.

Here's a short summary of what I do:

<script type="text/javascript" src="jmol/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="jmol/JmolCore.js"></script>
<script type="text/javascript" src="jmol/JmolApplet.js"></script>
<script type="text/javascript" src="jmol/JmolControls.js"></script>
<script type="text/javascript" src="jmol/JmolApi.js"></script>
<script type="text/javascript" src="jmol/JmolJSV.js"></script>

//init Jmol
var jmolInfo = {width : 370, height : 370, jarPath : 'jmol', jarFile : 'JmolApplet.jar', };
jmol = Jmol.getApplet('jmol', jmolInfo);
Jmol.script(jmol, 'load DATA \'inline\'\n ... snipped ... \nEND \'inline\'');

//init JspecView
var jspecInfo = {width : 370, height : 370};
jspec = Jmol.getJSVApplet('jspec', jspecInfo);
Jmol.jsvLoadInline(jspec, 'DATA \'inline\'\n ... snipped ... \nEND \'inline\'');

This fails because jspec._applet is null, meaning the call to loadInLine in JmolJSV.js#219 fails with Error calling method on NPObject.


  • Bob Hanson
    Bob Hanson

    This is not a bug. This is just not understanding how to synchronize the loading of the two applets. Since we don't know which applet will finish loading first, we have to issue a special command that waits for both to load before giving a script to either:

    // applet ids and commands to give only when all applets are ready;
    // also sets up a script sync pathway for Jmol/JSpecView.
    Jmol.setAppletSync([jsvApplet, jmolApplet], ["load acetophenone.jdx", null], true);

    Says "after these two applets are loaded, send jsvApplet its load command. The last parameter indicates that this is a Jmol/JSpecView connection, which is treated specially by Jmol.

    See http://chemapps.stolaf.edu/jmol/jspecview/jsvtest.htm

  • Bob Hanson
    Bob Hanson

    • status: open --> closed-rejected