是的。
像这样创建自己的 ApplicationServlet 扩展类:
public class MyApplicationServlet extends ApplicationServlet {
@Override
protected void writeAjaxPageHtmlVaadinScripts(Window window,
String themeName, Application application, BufferedWriter page,
String appUrl, String themeUri, String appId,
HttpServletRequest request) throws ServletException, IOException {
page.write("<script type=\"text/javascript\">\n");
page.write("//<![CDATA[\n");
page.write("document.write(\"<script language='javascript' src='./jquery/jquery-1.4.4.min.js'><\\/script>\");\n");
page.write("//]]>\n</script>\n");
super.writeAjaxPageHtmlVaadinScripts(window, themeName, application,
page, appUrl, themeUri, appId, request);
}
}
然后替换 web.xml 中的 Vaadin servlet(默认为com.vaadin.terminal.gwt.server.ApplicationServlet):
<servlet-class>com.example.MyApplicationServlet</servlet-class>
然后你可以在你的代码中调用 jQuery:
MyApplication.getMainWindow().executeJavascript(jQueryString);