There is a problem about using javascirpt to set value for textfield in vaa

TextField uknoTF= new TextField();
uknoTF.setDebugId(“ukno”);

getWindow().executeJavascript(
“document.getElementById(‘ukno’).value=‘123456’;”+
“document.getElementById(‘ukno’).focus();”
);
Problem:
When the value will take effect after TextField loses focus.
What are the best solution to solve it?
Thanks.

my project uses vaadin 6

Hi billy,

why using java script?

TextField uknoTF= new TextField(); uknoTF.setValue("123456"); uknoTF.focus(); But if you have to set the value per javascript you could add a ValueChangeListener and than focus per Java

Hi Wolfgang Wachsmuth,
Thank you for your answer.
sorry .I didn’t say clear. Value is from the hardware . so i should use javascript in vaadin 6.
i changed my code like this
TextField uknoTF= new TextField();
uknoTF.setDebugId(“ukno”);
unknoTF.setReadOnly(false);
getWindow().executeJavascript(
“document.getElementById(‘ukno’).readonly=true;”+
“document.getElementById(‘ukno’).value=‘123456’;”+
“document.getElementById(‘ukno’).readonly=false;”+);
it works well.
is there a way to make TextField visible?
if i set it visible ,but “document.getElementById(‘ukno’)” could not find the textfield.
sorry ,my english is not good.