title: vaadin javascript
body: <p>I am trying to integrate some js project into my vaadin app. And I tried the methods to invoke external javascript code, only successed on some easy/javascript.
  I tried the NativeJs lib 
  and the code is:</p>
  
  <pre><code>NativeJS nativeJScomponent = new NativeJS();
  nativeJScomponent.setJavascript("alert('foo');");
  nativeJScomponent.execute();
  addComponent(nativeJScomponent);
  </code></pre>
  
  <p>However, when I used some other code like: </p>
  
  <pre><code>String jsCode = "&lt;div /&gt;&lt;script type=\"text/javascript\"&gt;var d = new Date();" 
                    + "var time = d.getHours();" 
                    + "if (time &lt; 10) {document.write(\"&lt;b&gt;Good morning&lt;/b&gt;\");}&lt;/script&gt;";
  NativeJS nativeJScomponent = new NativeJS();
  nativeJScomponent.setJavascript(jsCode);
  nativeJScomponent.execute();
  addComponent(nativeJScomponent);
  </code></pre>
  
  <p>It failed to display content.</p>
  
  <p>And I also used the customelayout and label to run javascript. The same results came. </p>
  
  <p>Is there any method to integrate vaadin with js?</p>