This content has been marked as final.
Show 1 reply
-
1. Re: Main webapp HTML file as a template
mbarkley Feb 7, 2014 1:58 PM (in response to piotr.b)Hey Piotr,
You can access elements in your host page through the com.google.gwt.dom.client.Document class (it's just a thin wrapper over the javascript document API). However, here is some code you can add to a @Templated class to execute the <script> tags when a template is loaded:
@Templated public class HomePage extends Composite { @PostConstruct private void invokeJS() { final NodeList<Element> scripts = getElement().getElementsByTagName("script"); for (int i = 0; i < scripts.getLength(); i++) { System.out.println(scripts.getItem(i).getInnerHTML()); eval(scripts.getItem(i).getInnerHTML()); } } private native void eval(String script)/*-{ eval(script); }-*/;
I just tried this out, and I was able to get an embedded youtube iframe to work, so maybe this will be good enough for what you're trying to accomplish.
Cheers.