Urgent help regarding javascript execution with vaadin

Hello all,

I am executing javascript and fetching the svg for one of my vaadinForVisualization chart, the svg i got from current html page. I have actually created a textField and set its debug id to “textField123” and using the following javascript I am setting the value of the textField.

String jScript = //"alert('Hello java');" +
					"saveAsImg(document.getElementById(\"test1234\"));" +
					"function getImgData(chartContainer) {" +
					"   var chartArea = chartContainer.getElementsByTagName('iframe')[0]
.contentDocument.getElementById('chartArea');" +
					"   var svg = chartArea.innerHTML;" +
					"	document.getElementById('textField123').value = svg;}" +
					"function saveAsImg(chartContainer) {" +
					//"	alert('Insiide saveAsImg');" +
					"   var imgData = getImgData(chartContainer);" +


But the problem I am getting is, when from my application class I am trying to getValue of this TextField its returing the null value. But on that html page the textfield value is being set by the javascipt, but still its not returning the value of the textfield.

And I missed one thing to add above is that, when I click on the textfield manually then it shows and returns value for that text field.

Any help to regarding this would be a great help. Do write.


Changing the input element’s value via javascript doesn’t cause a changeEvent, which would cause the value to be propagated to server side. Although I would strongly advise to implement a cleaner solution using GWT you could try to dispatch the change event via javascript. Something like this:

(function() { 
    var evt = document.createEvent('HTMLEvents');
    evt.initEvent('change', true, false);
    var textField = document.getElementById('textField123');
    textField.value = 'svg';

Thanks a lot Johannes, I have finally got solution to my problem. Now I am able to get of svg through textbox.

By the way do you have idea on how can I take image of visualizationForVaadin charts?

Thanks once again. :grin: