User dfeb81947d
15-12-2009 13:46:23
Dear support,
In a JSP I have a javascript object that allow a
user to use wheter the awt marvin sketcher, whether the swing version.
The code is detailed below.
When changing a version of marvin I
always do as so: erase the folder "chemaxon" from the ancient version
and copy the new one from the package installed after downloading the
last version.
Last version I had was Marvin 5.1.4, and I wanted to upgrade to 5.2.6.
So
I completly delete the directory of marvin 5.1.4 and replace with the
directory of marvin 5.2.6. I remove java cache which is jdk1.5.
But when I start the JSP home page, I got a NullPointerException on : "this.setMolfile = function(molfile)".
The
attribute setMolfile is used to load a default molecule (aspirin) to
check wether the sketcher is working and is loaded or not.
the tag body of the jsp page contain a method onLoad which test if the browser is okay.
With
Marvin 5.1.4 everything works fine, but with Marvin 5.2.6 it seems that
when calling the method to test if the sketcher is properly installed
and loaded, actually he hasn't been initialized.
It happens
while using jdk 1.6.0_15 but knowing about problem with cache in this
version of jdk and marvin, I tried also with jdk 1.5.0_18.
Is there major change in Marvin 5.2.6 in the way he is loaded?
Knowing
the difference between 5.1.4 and 5.2.6, where could be the problem? I'm
looking for a solution for a few day (another solution than downgrading
Marvin to 5.1.4), and haven't found yet.
Any hint would help a lot.
Thank you very much for the help and advices.
Best Regards,
Jacques
if (!AP_Objects) {var AP_Objects = new Array();}
function MoleculeViewer(id) {
this.id;
this.viewerType=0;
this.viewerWidth=460;
this.viewerHeight=340;
this.viewerColor="#FFF5DE";
this._constructor = function(id) {
this.id=id;
AP_Objects[this.id] = this;
}
this.draw = function() {
var content = document.writeln(this.toHtml());
}
this.toHtml = function() {
switch (this.viewerType) {
case 0:
marvin_jvm="builtin";
marvin_gui = "awt";
msketch_name = this.id;
return msketch_begin("/TomcatApp/marvin/",this.viewerWidth,this.viewerHeight)+
msketch_param("molbg",this.viewerColor)+
msketch_param("background",this.viewerColor)+
msketch_param("undo","10")+
msketch_param("reactionSupport","false")+
msketch_param("preload", "MolExport")+
//msketch_param("detach", "hide")+
msketch_param("menubar","true")+
msketch_param("buttonmenubar","false")+
msketch_param("detach","hide")+
msketch_param("undetachByX","false")+
msketch_end();
case 1:
marvin_jvm="builtin";
marvin_gui = "swing";
msketch_name = this.id;
return msketch_begin("/TomcatApp/marvin/",this.viewerWidth,this.viewerHeight)+
msketch_param("molbg",this.viewerColor)+
msketch_param("background",this.viewerColor)+
msketch_param("undo","10")+
msketch_param("reactionSupport","false")+
msketch_param("preload", "MolExport")+
//msketch_param("detach", "hide")+
//msketch_param("menubar", "false")+
msketch_param("menubar","true")+
msketch_param("buttonmenubar","false")+
msketch_param("detach","hide")+
msketch_param("undetachByX","false")+
msketch_end();
default:
return 'Error: Unknown viewer.';
}
}
// Gets the currently displayed molecule as molfile
this.getMolfile = function() {
if (this.isEmpty()) {
return "";
}
switch (this.viewerType) {
case 0:
return document.getElementById(this.id).getMol("mol");
case 1:
return document.getElementById(this.id).getMol("mol");
}
}
// Sets the molecule in the viewer
this.setMolfile = function(molfile) {
try {
switch (this.viewerType) {
case 0:
if (molfile!="") {
document.getElementById(this.id).setMol(molfile);
}
else {
document.getElementById(this.id).setMol("\n -ISIS- 06090416142D\n\n
0 0 0 0 0 0 0 0 0 0999 V2000\nM END\n");
}
break;
case 1:
if (molfile!="") {
document.getElementById(this.id).setMol(molfile);
}
else {
document.getElementById(this.id).setMol("\n -ISIS- 06090416142D\n\n
0 0 0 0 0 0 0 0 0 0999 V2000\nM END\n");
}
break;
}
catch(excep) {
alert("The molecule viewer failed to initialize. Please check the
prerequisites for this viewer on the 'Home' tab, or contact
support."+e.name+", "+e.message);
}
}
// Checks if the viewer contains a molecule
this.isEmpty = function() {
var ret=false;
switch (this.viewerType) {
case 0:
ret=document.getElementById(this.id).isEmpty();
break
case 1:
ret=document.getElementById(this.id).isEmpty();
break
return ret;
}
this.reset = function() {
this.setMolfile("");
}
this._constructor(id);
}