Embed Javascript library in Vaadin 6 application


I try to integrate a Javascript library for pivot tables into a Vaadin 6 application. My init method looks like this:

public void init() {
try {

        Window mainWindow = new Window("Testpivot Application");
        CustomLayout cl;
        cl = new CustomLayout(new ByteArrayInputStream("<div id='pivot'></div>".getBytes()));
        mainWindow.executeJavaScript("$(function(){$(\"#pivot\").pivot([ {color: \"blue\", shape: \"circle\"}, {color: \"red\", shape: \"triangle\"}]

,{rows: ["color"]
,cols: ["shape"]

    } catch (IOException e) {
        // TODO Auto-generated catch block

[/code]I extended the class ApplicationService as follows:

public class MyApplicationServlet extends ApplicationServlet {

protected void writeAjaxPageHtmlHeader(BufferedWriter page, String title,
        String themeUri, HttpServletRequest request) throws IOException {
    super.writeAjaxPageHtmlHeader(page, title, themeUri, request);
    page.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + request.getContextPath() + "/VAADIN/pivottable/pivot.css\">");
    page.write("<script type=\"text/javascript\" src=\"" + request.getContextPath() + "/VAADIN/pivottable/jquery-1.8.3.js\"></script>");
    page.write("<script type=\"text/javascript\" src=\"" + request.getContextPath() + "/VAADIN/pivottable/jquery-ui-1.9.2.custom.js\"></script>");
    page.write("<script type=\"text/javascript\" src=\"" + request.getContextPath() + "/VAADIN/pivottable/pivot.js\"></script>");

[/code]The HTML written by the application seems to be ok. I checked it with the javascript tools of chrome. No error is thrown in the console. But the application is not showing the pivot table although a table structure is created in the div element by using the CustomLayout.

Any help is really appreciated.

Many thanks in advance,

No hints or tips on how to solve the problem?

Well, JavaScript library integration should go somewhat like that in Vaadin 6, so there’s probably some detail that you’re missing, and I don’t notice a problem immediately. Vaadin 6 does a lot of client-side layout calculations, so maybe the pivot table element is just sized wrong or something, and it’s not compatible with the layout it’s contained in. I understood that the HTML element of the pivot table that you use is created just fine as it should be. Can you inspect and experiment with its sizing with Firebug or Chrome developer’s tools?

Ok, had some time to investigate the problem and find the following. Seems that all is working well despite the fact that the table is not displayed correctly. Now I found out that once I maximize the browser window the table becomes visible. Afterwards I’m able to restore the prevoius size or change the browser window to any size without problems. So it finally looks to me as there is a sizing issue. But currently I have no idea on how to solve the problem.