Marvin remember the last structure after webpage refresh

User 39ade0cdf9

16-05-2014 02:21:25

Hello experts,


   Today, we encountered a strange problem, on windows XP+IE browser, we can run the demo db_search program  and static html page embeded with  a marvin sketch or marvin view applet very well.


 


However, when we build jsp+J2EE page, embed a marvin sketch and a marvin mview applet at the same time, the marvin js file path is given with custom label like this:


 


<script LANGUAGE="JavaScript1.1" SRC="<n:path path="/search/app/medicinesearch/marvin/marvin.js"/>"></script>


<script LANGUAGE="JavaScript1.1">


    msketch_name="msketch";


    msketch_begin("<n:path path="/search/app/medicinesearch/marvin"/>","500","500");


    msketch_param("molbg", "#F0F0F0");


    msketch_param("implicitH", "off");


    msketch_param("undo", "50");


    msketch_end();


</script>


 


<script LANGUAGE="JavaScript1.1" SRC="<n:path path="/search/app/medicinesearch/marvin/marvin.js"/>"></script>


<script LANGUAGE="JavaScript1.1">


 


mview_name = "mview";


mview_begin("<n:path path="/search/app/medicinesearch/marvin"/>","400","400");


mview_param("rows", "1");


mview_param("cols", "1");


mview_param("border", "1");


mview_param("background", "#ffffff");


mview_param("molbg", "#ffffff");


mview_param("editable", "2");


//msketch_param("isMyTemplatesEnabled", "true");


//msketch_param("queryAtoms", "");


//msketch_param("atomStrings", "alias");


//msketch_param("extraBonds", "arom,wedge");


mview_end();


 


</script>


 


============================================


After we draw a structure in Marvin sketch and submit to the same page, display results in marvin view, everything is ok. But if you press F5 to refresh the web page, the structures are still there, I suppose these structures should be cleared after refresh.


When I only embed a simple marvin sketch applet in a pure webpage without any other codes, and the file path is  given with custom label like: <n:path path="/search/app/medicinesearch/marvin"/>


The strcutures also is cleared! It works fine!


 


 


Attached is the applet information from help menu. Is there any solution for this problem?


Maybe the reason is mixing marvin sketch and mview applet at the same page? Cause we can get Javascript error like:


propertyChange('doc0=MDocument@fb8e1e[12a,12b]')


 


propertyChange('mol=RgMolecule@150c800[12a,12b]')

User 39ade0cdf9

16-05-2014 03:08:24

Maybe the reason is mixing marvin sketch and mview applet in the same page, we can get javascript error like:


propertyChange('doc0=MDocument@fb8e1e[12a,12b]')


propertyChange('mol=RgMolecule@150c800[12a,12b]')

User 39ade0cdf9

16-05-2014 04:45:45

I test this mixed applet code in v4.x   v5.11.3 and v6.2.2, it works fine in v4.x


I think this should be a new optional parameter in new version Marvin Applet, to cache molecule in browser, so that users won't lose their temporary drawn structures.


 


http://www.chemaxon.com/marvin/help/developer/sketchman.html#parameters.cacheMols


I think the parameters in document may be wrong, when set cacheMol to true, it's not saved in cache, and when false, it's saved in cache.


    msketch_param("cacheMols", "true");

User 39ade0cdf9

16-05-2014 07:03:53

Hello experts,


 


   Hope you can reproduce the problem using the below codes, I still can not clear the molecule when refresh browser under windows XP+IE8:


 


--------------------------


 


<script LANGUAGE="JavaScript1.1" SRC="./marvin/marvin.js"/>"></script>


 


<script LANGUAGE="JavaScript1.1">


 


    msketch_name="msketch";


 


    msketch_begin("./marvin","500","500");


 


    msketch_param("molbg", "#F0F0F0");


 


    msketch_param("implicitH", "off");


 


    msketch_param("undo", "50");


    msketch_param("cacheMols", "true");


 


    msketch_end();


 


</script>


 


 


 


 


 


<script LANGUAGE="JavaScript1.1">


 


 


 


mview_name = "mview";


 


mview_begin("./marvin","400","400");


 


mview_param("rows", "1");


 


mview_param("cols", "1");


 


mview_param("border", "1");


 


mview_param("background", "#dddddd");


 


mview_param("molbg", "#dddddd");


 


mview_param("editable", "2");


 


mview_param("cacheMols", "true");


 


//msketch_param("isMyTemplatesEnabled", "true");


 


//msketch_param("queryAtoms", "");


 


//msketch_param("atomStrings", "alias");


 


//msketch_param("extraBonds", "arom,wedge");


 


mview_end();


 


 


 


</script>


<br><br>


<input type="button" value="setMol" style="width:150px; height:50px;" onclick="document.mview.setMol(document.msketch.getMol('smiles:a0'));">

ChemAxon 2c555f5717

16-05-2014 07:27:26

Dear liuhai,


   I think, you miss the "legacy_lifecycle" parameter. We have switched it on by default, which means, when you hit refresh on a page than the same applet comes up, and the browser does not load a new one. You can switch it of this way:


msketch_param("legacy_lifecycle", "false");

   I hope, it helps.


   However cache_mols param only caches molecules that were downloaded from the site, molecules that you have set as custom abbrevgroup, or templates, and does not cache the drawn molecules.


Regards:
Balázs 

User 39ade0cdf9

16-05-2014 07:56:47










bzaicsek wrote:

Dear liuhai,


   I think, you miss the "legacy_lifecycle" parameter. We have switched it on by default, which means, when you hit refresh on a page than the same applet comes up, and the browser does not load a new one. You can switch it of this way:


msketch_param("legacy_lifecycle", "false");

   I hope, it helps.


   However cache_mols param only caches molecules that were downloaded from the site, molecules that you have set as custom abbrevgroup, or templates, and does not cache the drawn molecules.


Regards:
Balázs 



Dear Balázs,


  It seems work now, we will make more tests to confirm it, thanks!

ChemAxon 5433b8e56b

16-05-2014 12:47:56

Hi,


on one hand, turning off the legacy lifecycle seems to be a solution, it is slowing down the initialization of the applet after a refresh as far as I remember.


I can suggest an other solution which would be to explicitly set an empty molecule to the sketcher via the "mol" parameter, since with legacy lifecycle turned on, when a page refresh happens the applet parameters are reloaded, so the mol parameter with an empty structure will reset the sketcher which will have an empty canvas then.


You can find the parameter decription here.


Regards,
István