Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:40:20+00:00 2026-05-30T21:40:20+00:00

I need to execute Javascript from an external javascript library (which I left in

  • 0

I need to execute Javascript from an external javascript library (which I left in the public folder at the same level than client, server and shared). I need that the output of that JavaScript (which is a Canvas generated by ChemDoodle javascript library) is displayed within a SmartGWT VLayout. At first I tried adding the javascript code to an HTMLFlow object and then adding the HTMLFlow to the VLayout, however the HTMLFlow won’t execute the Javascript code (if I copy-paste the produced HTML into another browser window, it works). What I’m currently trying is to evaluate the javascript code with JSOHelper.eval(“java script code here”) resulting in a JavaScriptObject. However I don’t know how to “place” the result of the javascript execution inside the VLayout.

String javaScriptCode = 
"var viewerCanvas = new ChemDoodle.ViewerCanvas('viewerCanvas', 200, 200);\n" +
"var molFile = 'contentToBeDrawnByChemDoodleCanvas';\n" +
"var moleculeToShow = ChemDoodle.readMOL(molFile);\n" +
"viewerCanvas.loadMolecule(moleculeToShow);\n";

HTMLFlow hflow = new HTMLFlow("<script>\n"+javaScriptCode+"</script>");
vLayout.addMember(hflow);

However, as I said, this doesn’t work because HTMLFlow won’t execute the >script\> block (the boolean setting setEvalScriptBlocks(true) only applies for other URLs invoked from the HTMLFlow). So, with the JSOHelper class you can do:

JavaScriptObject jso = JSOHelper.eval(javaScriptCode); // without the <script> tags
// but the following line doesn't work, probably because jso is not a HTMLFlow
HTMLFlow flow2 = HTMLFlow.getOrCreateRef(jso);
// so then this doesn't work either, but I guess it shows where I want to get.
vLayout.addMember(flow2);

I have been trying to figure out how to do it with a JSNI method, but I don’t know how to refer to the vLayout from there (in javascript). Know that we have $doc and $win, but from there to the vLayout (which is inside a tab, which is inside other widgets), I don’t know how to get. I know there is a getElementByID method in javascript, but I don’t know how do I get the id of the vLayout and then how to associate that DIV (I guess) with the drawn canvas, so that the image appears there.

Could anyone explain me how do I manage (I guess through JSNI is the only way) to make that that javascript snippet is executed and the result (the generated canvas) displayed in the place where I need?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:40:21+00:00Added an answer on May 30, 2026 at 9:40 pm

    You better take a different approach, using JSNI to only handle JavaScript implementations, and delegating all higher level operations to the Java layer.

    Getting to know JSNI is crucial, so I suggest you start by diving into some documentation (GWT’s coding basics on JSNI is very useful).

    Having said that, best approach will be to have a native (JavaScript) script for the library instantiation as a separate file, and having it injected pre-load via the module’s (or the application’s) .gwt.xml file.

    Than you can wrap the code snippet within that file in a self executing block (i.e. (function() {...})(); as means of making sure it will run prior to onModuleLoad(), but this is just debugging sugar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I need to dynamically call and execute the javascript code generated from external
I need to execute a custom piece of JavaScript I got from some AJAX
I'm trying to execute JavaScript from plain text (from being entered by a client).
i need to execute some javascript functions from delphi code, but this functions fails
I need to retrieve some information from a Liferay server with Javascript. I build
I need to execute MDX query from command line (MS AS 2005). I have
I need to execute a http web request from Plesk's Task Scheduler (using shared
I need to execute a PowerShell script from within C#. The script needs commandline
I need to execute a SQL Query between two databases. Example: SELECT * from
I just don't want my WebBrowser to execute javascript at all. I don't need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.