Binding int-value to Textfield

Hey everybody,

is there a way to bin a int value to an textfield? so that everytime the in value is changed, the textfield value is also been changed?

or is the only way to do that a value changed listener at the int value?!

thx 4 help

If you mean binding and changing the value of a plain Java int, then no; there’s no way the textfield could know when the value changes except by continuously polling it in a background thread…

This is what the Vaadin databinding API is for: if you bind a Property as the datasource of the textfield, the property
notify the field about its value changes - although obviously you then need to use the Property API to change the value.

int i = 42;
Property prop = new ObjectProperty(i);
TextField tf = new TextField(prop);

prop.setValue(123); // the textfield is notified

ahh very good… i think this is exactly what i am looking for :smiley:

thank you very much