1 Reply Latest reply on Feb 7, 2014 1:58 PM by Max Barkley

    Main webapp HTML file as a template

    Piotr B Newbie



      I really need to access my main src/main/webapp/index.html from Errai.

      I have to load a flv player with javascript code and embed it into <div> existing in main index.html. It would be great if html templates loaded by Errai to the real website were also executing any <script...> in it but I think it's not possible.

      Hence, I have to load it from my main website (not a template). The player is sorrounded by other html elements like <tr> <table> etc. among some other elements which I want to refer to from Errai.


      When Errai loads template it does not replace any a placeholder but adds the whole template at some point in main html site.


      That said, I need to access single placeholders in main html. I can't use template...

        • 1. Re: Main webapp HTML file as a template
          Max Barkley Expert

          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:


          public class HomePage extends Composite {
            private void invokeJS() {
              final NodeList<Element> scripts = getElement().getElementsByTagName("script");
              for (int i = 0; i < scripts.getLength(); i++) {
            private native void eval(String 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.