Button to open a web page

User 9aa4619393

28-02-2012 10:50:18

Hi


I would like to add a button to a form that opens an external webpage.


It should  call a dynamic URL, i.e. I would like to pass for example a compound ID to pull up a web report on a compound. From what I understand I need to write a groovy script and paste it into the button Script field.


Do you by any change have an example script that I could use as a starting point that does something like this?


 


Many thanks


Anna

ChemAxon 6848e723bb

28-02-2012 11:14:27

Hi Anna,


there is a (quite complex) script, which does something similar: http://www.chemaxon.com/instantjchem/ijc_latest/docs/developer/scripts/patent_fetcher.html


The interesting part is at the end - you need to use the Desktop.browse(url) method to open a default browser. The lines before just prepare the URL to show.


If you need to include only values of some fields into the URL, then maybe dynamic URL field would be much simpler to use and maintain. (New standard field -> URL field -> dynamic). See Pubchem demo entity in the demo project bundled with IJC for some examples of those fields. The text field in the form makes the link clickable.


Filip Sedlak

User 9aa4619393

28-02-2012 13:36:58

Hi Filip


Thanks for your answer. The dynamic URL field is indeed much simpler.


Now however I have this long URL on my Form....is there a way to give it a display name, so that it only shows something like "Compound Report" instead of the URL?


 


Kind regards


Anna

ChemAxon 6848e723bb

28-02-2012 14:41:08

Hi Anna,


each field has a "Display name", which is by default displayed in the border of the text field widget. Also, you don't need to display the whole URL; the beginning should be enough. Unfortunately, as of IJC 5.8, it is not possible to overwrite the displayed link.


If this is not sufficient, then the button script can be used.


Regards,


Filip