1

I have an application based on Vaadin 7, now I want to add my Components into CustomLayout the problem is that CustomLayout ignores - header part of template (static html) file so resources that described there ignored too. Static html files are not part of Vaadin application and they generated dynamically. How could I load JS and CSS files (that belongs to static html) on client side without annotations:

@JavaScript; @StyleSheet

and also approach with JavaScript.execute() also isn't good approach.

Igor Masternoy
  • 436
  • 1
  • 11
  • 36

1 Answers1

2

Why exactly these solutions are not good for you? Based on my experiences these work just fine. However, there is another solution: to just include an external javascript file into the page, extend the ApplicationServlet class, and override the writeAjaxPageHtmlVaadinScripts method.

`@Override
protected void writeAjaxPageHtmlVaadinScripts(Window window, String themeName, Application application, BufferedWriter page, String appUrl, String themeUri, String appId, ServletRequest request) throws ServletException, IOException {
  page.write("<script type=\"text/javascript\">\n");
  page.write("//<![CDATA[\n");
  page.write("document.write(\"<script language='javascript' src='" + appUrl + "/VAADIN/scripts/jquery/jquery-1.4.4.min.js'><\\/script>\");\n");
  page.write("document.write(\"<script language='javascript' src='" + appUrl + "/VAADIN/scripts/highcharts/highcharts.js'><\\/script>\");\n");
  page.write("document.write(\"<script language='javascript' src='" + appUrl + "/VAADIN/scripts/highcharts/modules/exporting.js'><\\/script>\");\n");
  page.write("//]]>\n</script>\n");
  super.writeAjaxPageHtmlVaadinScripts(window, themeName, application,
      page, appUrl, themeUri, appId, request);
}

`

See this post for more details: How to add d3 (javascript) to a vaadin application?

Community
  • 1
  • 1
chicxurug
  • 106
  • 1
  • 3