Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to add valueChange Event to a Text field
I have the following code and I am trying to create an event when a value changes in a Text field, but the event never fires. What am I doing wrong?
public AddressForm() {
private final TextField _zipCode;
public class AddressForm extends Form implements ClickListener, Property.ValueChangeListener {
_zipCode = (TextField) getField("zipcode");
_zipCode.setImmediate(true);
_zipCode.addListener(this);
}
@Override
public void valueChange(Property.ValueChangeEvent event) {
if (event.getProperty() == _zipCode) {
updateZipCity();
}
}
}
Thank You
Peter
Your code doesn't appear to be legal Java...confusing constructors and class declarations. You need something more like:
import com.vaadin.data.Property;
import com.vaadin.ui.Form;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
public class AddressForm extends Form implements ClickListener, Property.ValueChangeListener {
private final TextField _zipCode;
public AddressForm() {
_zipCode = (TextField) getField("zipcode");
_zipCode.setImmediate(true);
_zipCode.addListener(this);
}
@Override
public void valueChange(Property.ValueChangeEvent event) {
if (event.getProperty() == _zipCode) {
updateZipCity();
}
}
@Override
public void buttonClick(ClickEvent event) {
// TODO Auto-generated method stub
}
}
Sorry!
Actually the code you entered is what I have, I messed up my code when I was pasting ii into the message.
the only difference I have is I don't have the ' @Override' on the public void valueChange(ValueChangeEvent event)
public void valueChange(ValueChangeEvent event) {
Property property = event.getProperty();
}
If I add @Override I get error message ' method does not override or implement a method from a supertype
@Override'
@Override
public void valueChange(ValueChangeEvent event) {
Property property = event.getProperty();
}
I am using vaadin-6.3.0.nightly-20100406-c12338.jar
I don't know what I did, probably fixed one of the imports, but it's working now.
Thank You