AbstractJavaScriptComponent in Window error


I have created a custom AbstractJavaScriptComponent wich is working fine.

I have found a problem when inserting the component in a Window though.

When calling this.getElement() from JavaScript I get the DOM element where my component must be created. In a regular layout when this is called, the returned div is already attached to DOM so it has a size. I have realized that when doing this in a Window it has not been yet attached to DOM and it is causing me many problems.

Is it a bug or is this the expected behaviour?

I have found a workaroun in case someone needs it.


Hi Francesco

i tried the same thing to get HIghcharts working. With a custom AbstractJavaScriptComponent i got it working, but trying to put that stuff in a window brought me to the same misbehaviour.
Actual i am starting to get this work by using getPage and put highcharts directly to execute js.

I am not sure if that works, so i am interested in your workaround …

greets Andi


there is a workaround (codesnipplets) how to get Highcharts 3.0 working within a window

// create a label and setb contentmode to html
label.setValue("<div id=\"aNewPie\" style=\"width:400px; height:400px;\"></div>");


//Create a Window
Window window = new Window("Test Chart");


// After all has been initialized and loaded a execute on a JavaScript has to be performed
// with the id of the div created before using the highcharts code

window.getUI().getPage().getJavaScript().execute("$(function() {$('#aNewPie').highcharts({chart: {type: 'bar'},title: {text: 'Fruit Consumption'}," + " xAxis: {" +
        "   categories: ['Apples', 'Bananas', 'Oranges']

" + " }," + " yAxis: {" + " title: {" + " text: ‘Fruit eaten’" + " }" + “},” + “series: [{” + " name: ‘Jane’," +
" data: [1, 0, 4]
" + “}, {” + " name: ‘John’," + " data: [5, 7, 3]
" + " }]" + “});” + “});”);

// Now someone can make the highcharts code filled up with own values

Hope this helps someone :wink: