Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
javascript API
Dear Vaadin experts,
I am trying to understand how I can put javascripts widgets on page. I tried pasting the example below in the demo page with no response and my code doesn't appear to do anything either. The widgets I've seen sound easy - "just cut and past on your web site" - I know I'm missing something. I've looked through related posts and still am a bit lost.
I copied the one code below from http://free.antivirus.com/widgets/
<script type="text/javascript" src="http://cs68.clearspring.com/o/46f38cdabe642cf9/4b4fbf2bf08d9040/49edba2975af74a0/4c2584a0/widget.js"></script>
So I tried coding, my latest attempt:
***
String this1 = "<script type=\"text/javascript\" src=\"http://cs68.clearspring.com/o/46f38cdabe642cf9/4b4fbf2bf08d9040/49edba2975af74a0/4c2584a0/widget.js\"></script>";
mainWindow.executeJavaScript(this1);
****
I'd like to run this in a panel, and while I got a lot farther with the Label and XHTML options, I never got output.
l1 = new Label("iframe src=\"http://cs68.clearspring.com/o/46f38cdabe642cf9/4b4fbf2bf08d9040/49edba2975af74a0/4c2584a0/widget.js\"></script>"+
"</iframe>",Label.CONTENT_XHTML);
Panel p1 = new Panel();
p1.addComponent(l1);
mainWindow.addComponent(p1);
Any hints would be appreciated.
Thanks!
Keith
Keith Smelser: So I tried coding, my latest attempt:
***String this1 = "<script type=\"text/javascript\" src=\"http://cs68.clearspring.com/o/46f38cdabe642cf9/4b4fbf2bf08d9040/49edba2975af74a0/4c2584a0/widget.js\"></script>";
mainWindow.executeJavaScript(this1);
***
Window.executeJavaScript expects a plain JavaScript string, not a URL. So you need to retrieve the contents of that URL in the server, store it into a string, and then pass that string to executeJavaScript.