Peter8
(Peter Czurak)
1
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
David3
(David Wall)
2
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
}
}
Peter8
(Peter Czurak)
3
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
Peter8
(Peter Czurak)
4
I don’t know what I did, probably fixed one of the imports, but it’s working now.
Thank You